I am rewriting my URLs like this:
RewriteRule ^/?page/([a-z0-9\-]*)/ /page.php?url=$1 [L]
Now I changed an URL and want to redirect it with 301:
Redirect 301 /page/example-old/ /page/example-new/
The problem: It adds the URL param. Result is:
/page/example-new/?url=example-new
What am I doing wrong? I want the redirect without the added URL param.
CodePudding user response:
If you are using mod_rewrite already, it is usually best to implement redirecws with mod_rewrite as well:
RewriteRule ^/?page/example-old/ /page/example-new/ [R=301,L]
RewriteRule ^/?page/([a-z0-9\-]*)/ /page.php?url=$1 [L]
That way the first rule prevents the second rule from running because the first rule uses the L
(last) flag.