OSC Htaccess捕获所有重定向

时间:2014-12-23 07:02:52

标签: apache .htaccess mod-rewrite redirect

我有一个名为ice.domain.com的子域名,我有一个名为icedomain.com的新域名 我想要捕获所有URL重定向到icedomain但我已经有一些重定向设置。 我尝试了301重定向,但重写规则将停止工作

Options +FollowSymLinks
redirect 301 / http://icedomain.com/
RewriteEngine on
RewriteCond %{QUERY_STRING} ^products_id=28$
RewriteRule ^product_info\.php$ http://www.icedomain.com/ProductDetails.asp?ProductCode=58B-9x12-10- [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=29$
RewriteRule ^product_info\.php$ http://www.icedomain.com/Danfoss-s/1679.htm [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=30$
RewriteRule ^product_info\.php$ http://www.icedomain.com/Danfoss-s/1679.htm [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=31$
RewriteRule ^product_info\.php$ http://www.icedomain.com/Danfoss-s/1679.htm [R=301,L]

1 个答案:

答案 0 :(得分:1)

这将重定向未被其他规则重定向的所有内容:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST}   !^www\.icedomain\.com [NC]
RewriteRule ^/(.*)         http://www.icedomain.com/$1 [R=301]
RewriteCond %{QUERY_STRING} ^products_id=28$
RewriteRule ^product_info\.php$ /ProductDetails.asp?ProductCode=58B-9x12-10- [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=29$
RewriteRule ^product_info\.php$ /Danfoss-s/1679.htm [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=30$
RewriteRule ^product_info\.php$ /Danfoss-s/1679.htm [R=301,L]
RewriteCond %{QUERY_STRING} ^products_id=31$
RewriteRule ^product_info\.php$ /Danfoss-s/1679.htm [R=301,L]