【问题标题】:mod_rewrite redirect is appending url args I dont wantmod_rewrite 重定向正在附加我不想要的 url 参数
【发布时间】:2012-02-17 19:06:30
【问题描述】:

我有很多旧网址需要重定向。该网站通过 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 中显示为任何其他请求(对于非重定向)?

【问题讨论】:

    标签: mod-rewrite redirect seo


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 2017-04-12
    • 1970-01-01
    • 2018-05-02
    • 2022-01-08
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多