我的htaccess代码如下所示
Redirect 301 /coupon/coupon-codes-for-home-shopping-network.htm http://www.domain.com/coupon/coupon-code-for-hsn.com
Redirect 301 /coupon/coupon-code-for-shopping.hp.com http://www.domain.com/coupon/coupon-codes-for-hp-home-store.htm
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]
</IfModule>
问题是如果我导航到http://www.domain.com/coupon/coupon-codes-for-home-shopping-network.htm,它会重定向到http://www.domain.com/coupon/coupon-code-for-hsn.com?url=coupon/coupon-codes-for-home-shopping-network.htm
我需要删除这些301重定向的查询字符串网址。请指教。感谢
答案 0 :(得分:1)
首先混合mod_alias和mor_rewrite并不是一个好主意。坚持使用mod_rewrite,因为它更强大,更灵活。你有这样的规则:
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^coupon/coupon-codes-for-home-shopping-network\.htm$ /coupon/coupon-code-for-hsn.com [L,NC,R=301]
RewriteRule ^coupon/coupon-code-for-shopping\.hp\.com$ /coupon/coupon-codes-for-hp-home-store.htm [L,NC,R=301]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/coupon/
RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]
</IfModule>