views:

34

answers:

2

I am trying to do a 301 redirect of everything from an old subdomain to a new.

I have a simple .htaccess

Redirect 301 / http://www.smartphonesoft.com/

However if I goto the old URL with a subdir, it tries to redirect to the new domain with a subdir and fails.

ie

http://forum.smartphonesoft.com/reminder/

goes to

http://www.smartphonesoft.com/reminder/

When I would like it to goto

http://www.smartphonesoft.com/

How can I have everything simply redirected to the new domain root?

A: 

Assuming your server has support for mod_rewrite, you can do this:

RewriteRule . http://www.smartphonesoft.com/ [R=301,L]

Alternatively, sticking to mod_alias, this should also work (but I haven't tried it):

RedirectMatch 301 .* http://www.smartphonesoft.com/
Tim Stone
+1  A: 

With Redirect you define the base path (path prefix) that is to be redirected; every path beyond that is redirected while just replacing the base path with the new base path.

If you want to stick with mod_alias, you can use RedirectMatch and omit the match:

RedirectMatch 301 ^/ http://www.smartphonesoft.com/
Gumbo
+1 for posting the answer I should have thought of originally, while I was editing, heh.
Tim Stone
thanks, that seems to work for everything, except.... http://forum.smartphonesoft.com/reminder/
kitenski