mod_rewrite 重定向正在附加我不想要的 url 参数
我有很多旧网址需要重定向。该网站通过 mod_rewrite 规则点击 index.php?url=whatever
来工作。但是,我不希望用户在重定向的情况下看到参数:
<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 是否与其他请求一样(对于非重定向)?
I have a lot of old urls that I need to redirect. The site works by hitting an index.php?url=whatever
via a mod_rewrite rule. However, I dont want the user to see the arg in the case of a redirect:
<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>
So in the case of:
(the domain)/clients_whatever2.html
they are being redirected to:
(the domain)/client-list/whatever2?url=/client-list/whatever2
but it should simply read as:
(the domain)/client-list/whatever2
How to do the redirect so that it shows up in the browser url as any other request (for a non-redirect)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
?
附加到规则目标以删除原始查询字符串参数,即Append a
?
to the rule target to drop the original query string params i.e.