Remove request string from redirected URL using htaccess

I use the following code to redirect traffic to the spesific page (this traffic comes through google from the old site that was used to use my ip servers)

RewriteRule ^viewtopic.php?/?$ http://www.myurl.org.uk/ [L,R=301] 

As I understand it, this ^viewtopic.php?/?$ Should cancel the query string, but it does not work. Any help was appreciated.

URL example

 http://www.myurl.org.uk/viewtopic.php?f=3&t=44207&start=2265 

Redirect Exit

 http://www.myurl.org.uk/?f=3&t=44207&start=2265 
+7
source share
1 answer

You were close to the answer ... Do you have one ? on the other hand. Put it on the redirection side to remove the query string:

 RewriteRule ^viewtopic.php http://www.myurl.org.uk/? [L,R=301] 

In 301 redirects, mod_rewrite usually adds the complete query string. But accommodation ? at the end of your rewritten URL without the corresponding flag, [QSA] ("querystring append") will instead use the empty query string that you specified.

+19
source

All Articles