Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

redirect help

Joined
Nov 11, 2005
Posts
2,334
Reaction score
575
I want to redirect every page from an old domain to one page on a new domain.

I've found this code:
## Each and every page on old domain redirects to single page
## By appending question mark to new domain, query strings are removed
RewriteEngine on
RewriteCond %{HTTP_HOST} old\.com$
RewriteRule .* http://www.new.com/? [L,R=301]

If I'm redirecting olddomain.co.uk to newdomain.co.uk do I replace old\.com with olddomain\.co.uk and www.new.com with www.newdomain.co.uk?
 
The new domain has no knowledge of the old domains existence.
The redirect script has to be forwarding FROM the old domain TO the new domain.
 
Thanks Adam. Old domain is no longer live. I was hoping to put the code in new domains .htaccess if possible.

Are you redirecting the old domain via registrar DNS instead ? If so is it a wild card redirect which redirects all inner URL structures ? Id still personally point the old domain to a hosting account as an addon domain and then use the htaccess, give your alot more control over everything.

If your not and the old domain is actually not being used at all... eg its expired or something then there is no way of redirecting old URL's .
 
At the moment I have parked the old domain on the new domain and redirected it to the new one. That works fine for the domain itself (as in www.olddomain.co.uk goes to www.newdomain.co.uk), but pages on the old domain throw up a 404 error page.

I've done the above via the Parked Domain icon on the new domain's cPanel.

Although the old domain is no longer live, it still gets traffic from search engines (obviously that will dry up over time, but meanwhile I don't want the eror page showing).
 
Yeah as Daz and I said , use addon domain. It will then create a folder for you to add the .htaccess, it will give you much more control over what gets redirected and what doesnt.

The way your doing it at the moment isnt a wildcard redirect or anything, its root to root.
 
Brillliant! Thanks Daz and Adam.

And what code do I put in the .htaccess for the old domain?
 
I think the code I posted at the top will do it but if not post again and ill dig out what im using on some of my sites.

Another one I use is :

redirectMatch 301 ^/ http://www.newdomain.co.uk/
 
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]

I think this is the technically correct way of doing it.

Another one I use is :

redirectMatch 301 ^/ http://www.newdomain.co.uk/

This is useful if you want the root domain to redirect to the new root domain only so you can then add individual redirects below?

For instance, if you combine two sites but the permalink structure isn't compatible. (just going on what I've used before - not 100% certain).


This is a useful list of rules which is handy to have bookmarked btw
https://github.com/phanan/htaccess

I haven't tested many of them but it's a good place to start. I've yet to find a reliable reference where every single example works 100% of the time. There will always be oddities in host set-up, software iterations and so on.
 
Last edited:
This is useful if you want the root domain to redirect to the new root domain only so you can then add individual redirects below?

You absolutely right, just released ive used it on a site which i redirect ALL requests to a single page rather than retaining the same URL structure. Apologies diablo, first one should do it, second is something different.
 
Really appreciate the help.

And it's working a treat!
 
Last edited:

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Register for the auction
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom