htaccess Rewrite Rules appending parameter?

巧了我就是萌 提交于 2021-01-28 07:05:04

问题


Our original urls began with a parameter and the following rewrite works to redirect them (thanks to Jon Lin).

However, the original parameter is being appended to redirect, so that

RewriteEngine On
RewriteCond %{QUERY_STRING} ^old-page$
RewriteRule ^$ /newpage [R=301,L]

ends up going to mydomain.com/newpage?old-page

Any idea how to fix? thanks again, Geoff


回答1:


Have it like this to strip off existing query string:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^old-page$ [NC]
RewriteRule ^$ /newpage? [R=301,L]

Take note of ? at the end of target URI, that is used to strip-off existing query string.



来源:https://stackoverflow.com/questions/21882533/htaccess-rewrite-rules-appending-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!