简体   繁体   中英

htaccess 301 redirect — remove a string

I am trying to do this htaccess 301 redirect, but I am stuck.

What I want is to remove a string in the URL, the string is: style=5&

I want the redirect it so all pages that may get that string in the URL will be removed. -- Thanks in advance.

FROM:

/viewtopic.php?style=5&f=45&t=1980&p=19136

TO:

/viewtopic.php?f=45&t=1980&p=19136

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.+?&)?style=5(?:&(.*))?$ [NC]
RewriteRule ^viewtopic\.php$ %{REQUEST_URI}?%1%2 [R=302,NC,L]

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