1

我的 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 重定向的查询字符串 url。请指教。谢谢

4

1 回答 1

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>
于 2013-07-02T10:53:18.347 回答