1

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?

Axel
  • 62
  • 1
  • 5
  • strange, try to work with 302 instead of 301 at first. If you made one error before the 301 browser cache may prevent you from testing the new configuration. – regilero Jan 14 '13 at 13:27

1 Answers1

1

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.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • Thanks for the reply. But this didn't work. The longer urls still won't work. – Axel Jan 19 '13 at 19:09
  • @Axel There's nothing different with longer URLs. If this doesn't work, there are other rules or configurations involved. Either on xenolith.ws or on xeno-mods.com side. Can you show in your question with an example what happens with longer URLs? Doesn't work covers a pretty wide range. – Olaf Dietsche Jan 19 '13 at 19:56
  • Well you can just paste this in your browser: http://xenolith.ws/mod/122 It'll give you a 404 Error. – Axel Jan 20 '13 at 13:03
  • @Axel http://xenolith.ws/mod/122 gives a 404, but http://xenolith.ws/mods/122 redirects to http://xeno-mods.com/mods/122. I've just setup a virtual host on my system and created a .htaccess with `RedirectMatch .* http://xeno-mods.com$0` and it works. As an alternative `Redirect / http://xeno-mods.com/` works as well. I'd say, you have other rules in your configuration, which prevent proper redirecting. – Olaf Dietsche Jan 20 '13 at 14:05
  • I found it, thanks for pointing that out. I needed to add "Options -MultiViews", which makes names like mod, user possible. Otherwise it will remove them or something like that, because they are reserved. – Axel Jan 20 '13 at 22:48