正如我曾经遇到过很幸运与管理得到查询字符串来重定向正确以前只是路过查询字符串参数,和整个本网站和站长世界的涵盖范围广泛的建议供查询字符串重定向似乎是“处理它作为一个RewriteCond查询字符串”,我试图使用以下类型的规则为一组约10个URL。的RewriteCond%{QUERY_STRING}中的mod_rewrite(动态到静态URL)无法正常工作
实例网址:
http://www.example.org/training_book.asp?sInstance=1&EventID=139
我到目前为止有:
RewriteCond %{QUERY_STRING} ^training_book.asp\?sInstance=1&EventID=139
RewriteRule /clean-landing-url/ [NC,R=301,L]
所以,我希望发生的是
http://www.site.org/training_book.asp?sInstance=1&EventID=139 301> http://www.site.org/clean-landing-url
,而是正在发生的事情是这样的:
http://www.site.org/training_book.asp?sInstance=1&EventID=139 301> http://www.site.org/training_book.asp/?sInstance=1&EventID=139
它在查询字符串之前追加正斜杠,然后解析完整的URL(显然是404ing。)
我错过了什么?这是真正的%{QUERY_STRING}参数的正则表达式问题吗?
在此先感谢!
编辑 -
这是我到目前为止的地方。
基于从下面@TerryE的建议,我已经尝试实现以下规则。
我有具有以下参数的一组URL的:
http://www.example.org/training_book.asp?sInstance=1&EventID=139
http://www.example.org/training_book.asp?sInstance=2&EventID=256
http://www.example.org/training_book.asp?sInstance=5&EventID=188
等
这需要重定向到
http://www.example.org/en/clean-landing-url-one
http://www.example.org/en/clean-landing-url-two
http://www.example.org/en/clean-landing-url-three
等
这是确切的我目前使用的htaccess文件结构,包括“简单”redir的完整示例它们是目前工作正常(注 - http://example.com>http://www.example.com重定向在httpd.conf执行)学分
#301 match top level pages
RewriteCond %{HTTP_HOST} ^example\.org [NC]
RewriteRule ^/faq.asp /en/faqs/ [NC,R=301,L]
在该块中的所有URL属于这种类型。所有这些网址都很完美。
#Redirect all old dead PDF links to English homepage.
RewriteRule ^/AR08-09.pdf /en/ [NC,R=301,L]
此区块中的所有网址均属此类型。所有这些网址都很完美。
的问题是在这里:我仍然不能得到以下类型的URL重定向。根据@TerryE的建议,我试图改变语法如下。下面的块不能正常工作。
#301 event course pages
RewriteCond %{QUERY_STRING} sInstance=1EventID=139$
RewriteRule ^training_book\.asp$ /en/clean-landing-url-one? [NC,R=301,L]
的这个输出是
http://staging.example.org/training_book.asp/?sInstance=1&EventID=139
(这是目前适用于staging.example.org,将适用于将example.org)
(我有 “隐藏” 了一些在最初的问题中将其从training_book更改为event_book的实际语法,但我已将其更改为尽可能真实。)
感谢您的输入@TerryE,但这并没有改变行为。 example.com/news.asp正确转到example.com/zh/news,这是一个很好的简单重定向。 目前有一个虚拟主机设置为在上线之前测试重定向,位于new.example.com。 这是我想重定向的确切网址,使用站点名称的例子来代替: http://example.org/training_book.asp?sInstance=1&EventID=139 > http://new.example.com/clean-landing-url 我错过了什么?预先感谢您的任何进一步的想法。 – 2012-07-23 15:31:20
@BobC,从第一次重定向到.../en/...,你显然已经得到了一些可能会干扰的规则。更新您的Q以包含所有规则,以便我们可以看到发生了什么。 – TerryE 2012-07-23 18:00:34
嗨特里 - 我已根据要求更新。非常感谢您的帮助 – 2012-07-26 08:51:13