简体   繁体   中英

htaccess Rewrite Rules appending parameter?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM