mod_rewrite重定向是追加我不想要的url args

时间:2012-02-17 19:06:30

标签: mod-rewrite redirect seo

我需要重定向很多旧网址。该网站通过mod_rewrite规则点击index.php?url=whatever来工作。但是,我不希望用户在重定向的情况下看到arg:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule ^clients_whatever1\.html$   /  [R]
    RewriteRule  ^clients_whatever2\.html$   /client-list/whatever2  [R]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>

所以在:

的情况下

(the domain)/clients_whatever2.html

他们被重定向到:

(the domain)/client-list/whatever2?url=/client-list/whatever2

但它应该简写为:

(the domain)/client-list/whatever2

如何进行重定向,使其在浏览器网址中显示为任何其他请求(对于非重定向)?

1 个答案:

答案 0 :(得分:0)

在规则目标中附加?以删除原始查询字符串params,即

RewriteRule ^clients_whatever1\.html$   /?  [R,L]
RewriteRule  ^clients_whatever2\.html$   /client-list/whatever2?  [R,L]