I need to redirect all url’s that contain the parameter ?lang=
to my base url.
For example: If www.example.com/?lang=ru
redirect to www.example.com
.
I have tried with RedirectMatch but it’s not working.
Thanks!!!
I need to redirect all url’s that contain the parameter ?lang=
to my base url.
For example: If www.example.com/?lang=ru
redirect to www.example.com
.
I have tried with RedirectMatch but it’s not working.
Thanks!!!
2
Answers
Using Regular Expressions
If you want to use a Regular Expression to redirect something, use the RedirectMatchdirective:
RedirectMatch “^/lang=ru?.html/?$” “http://example.com/newfile.php“
Don’t forget have mod_rewrite on in your apache configuration, and other configuration neccessary for enable your htaccess file.
The
Redirect*
directives do not handle the query string so you need to use URL rewriting instead.