htaccess rewrite all URLs

Maljonic

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,297
Does anyone know if it's possible to rewrite the domain name of all the URLs on a website?

I mean if you move your site to a different address but all the pages keep the same name so you want each page to redirect to it's counterpart at the new address using .htaccess at the old address.

Usually I've just done a seperate redirect for each page, but it occured to me that there MUST be a way to do it with one or two lines instead of 30, 40 or 300 etc when the only thing that's changing is the domain name.
 

Maljonic

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,297
Oh wait, I found this after searching a bit:

Code:
Redirect 301 /  http://www.new-domain.com/

It can't be that simple can it?
 

Deebs

Chief Arsewipe
Staff member
Moderator
FH Subscriber
Joined
Dec 11, 1997
Messages
9,076,937

Maljonic

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,297
Anyway I just tried the example I posted and it does work after all. For instance I've moved felinefights.com to catclash.com and put only this in the.htaccess of felinefights.com

Code:
RewriteEngine on

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

and it seems to work: Cat Clash - Where the World's Foremost Felines Come to Do Battle

edit: gah, it put the link text in for me and I can't change it, but if you look in the status bar you can see the url:

felinefights.com/faq.php
 

GReaper

Part of the furniture
Joined
Dec 22, 2003
Messages
1,983
Really varies on the setup.

If the old domain is served under a different directory then a Redirect statement will work perfectly. However if you've got two sites using the same directory then you have to use mod_rewrite.
 

Users who are viewing this thread

Top Bottom