Daniel S
Daniel S

Reputation: 13

htaccess 301 redirect with ? (question mark) in URL not working

This is probably a simple question, but I can not find why the 301 with an ? in the URL is not working. I have done a 301 redirect in the .htacces file but it´s not working. Other 301-redirects are working except for the one with a question mark in the URL.

I want http://www.example.com/?forum=2115543 redirected to http://www.example.com but the simple standard 301-redirect doesn´t work.

Example in .htaccess: Redirect 301 /?forum=2115543 /

Upvotes: 1

Views: 1423

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

You can not match a query string with Redirect (mod_alias). You need to use mod_rewrite.

You can give this a try.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^forum=(.+) [NC]
RewriteRule ^ /? [R=301,L]

Upvotes: 0

Related Questions