我有很多旧的网址,我需要重定向。该站点通过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
如何进行重定向,以便它作为任何其他请求(对于非重定向)显示在浏览器url中?

最佳答案

将a?附加到规则目标以删除原始查询字符串参数,即。

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

09-28 07:47