【发布时间】:2012-03-12 07:44:02
【问题描述】:
我想将一组页面重定向到新域,但到目前为止我无法实现。
我想要任何以以下开头的请求:
http://www.mydomain.com/wiki/index.php?title=CSV_to_QuickBooks_Converter
被重定向到:
www.StatementConverter.com
例子:
http://www.mydomain.com/wiki/index.php?title=CSV_to_QuickBooks_Converter_-_ABCXYZ
应该被永久重定向到:
http://www.StatementConverter.com
我的 .htaccess 看起来像这样:
# Prevent viewing of the .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Cache files for one month
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# trying to redirect these pages to new website
RewriteCond %{QUERY_STRING} ^(.*)CSV_to_QuickBooks_Converter$ [NC]
RewriteRule ^.*$ http://www.statementconverter.com/ [R,L]
到目前为止,显示的是原始页面(未应用我的规则)。
解决方案:
结合我收到的答案,我正在使用它并且它有效:
RewriteCond %{QUERY_STRING} ^title=CSV_Statement_to_QuickBooks_Converter [NC]
RewriteRule ^.*$ http://statementconverter.com/? [R,L]
我添加了“?”在 RewriteRule 的末尾,以防止将原始 query_string 附加到新 URL。
【问题讨论】:
-
结合这两个答案,这就是我正在使用的:
RewriteCond %{QUERY_STRING} ^title=CSV_Statement_to_QuickBooks_Converter [NC] RewriteRule ^.*$ http://statementconverter.com/? [R,L]
标签: apache mod-rewrite redirect