Axel
Axel

Reputation: 62

RedirectMatch does not work with longer urls

I have a problem with RedirectMatch 301. It works fine on the top level domain and one variable attached, i.e.

http://xenolith.ws/ redirects to xeno-mods.com
http://xenolith.ws/explore redirects fine as well
http://xenolith.ws/mods/122 does not work

My RedirectMatch looks like this:

RedirectMatch 301 ^/(.*)$ http://xeno-mods.com/$1

What am I missing?

Upvotes: 1

Views: 140

Answers (1)

Olaf Dietsche
Olaf Dietsche

Reputation: 74078

While testing your configuration, don't use 301, see this answer Tips for debugging .htaccess rewrite rules

Depending on your configuration and where you have this RedirectMatch, the leading / will already be removed or not. You might try

RedirectMatch .* http://xeno-mods.com/$0

or

RedirectMatch .* http://xeno-mods.com$0

You can also just use Redirect

Redirect / http://xeno-mods.com/

which redirects all requests to the new domain.

Don't forget to reload in your browser, because of your previous 301 tests, the browser might have already cached some results.

When the redirect works as you expect, you can insert the 301 status code again. But without it, the testing is much easier.

Upvotes: 1

Related Questions