Recently, I uploaded a new site to an existing domain and I'd like to figure out how I can forward all links to said domain to a new domain.

I'm looking for a wordpress solution if possible, but in the end I I seem myself writing a small header script that I will paste into ever directory's index file saying header('Location:http://xxx.yyy.zzz')

Is there a cleaner way to do this without having to resort to managing the whole file structure?

No, I do not have access to the apache runtime. Unfortunately it is a shared-host server.

Thanks in advance.

1 Answer 1


You need to do 301 redirects from the old URLs to the new URLs. If all you did was change the domain name then this will work for you (place this in a file called .htaccess in your root web directory):

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

If the domain is the same you'll need to do 301 redirects for each page. If the new URLs follow a pattern related to old URLs you can do this all with one rule like above but how that is done will depend on the URLs. If there is no pattern you can do them all one at a time using the same technique as above:

redirect 301 /old/old.htm http://www.you.com/new.htm

Just write that line in your .htaccess file for each page you wish to redirect.

I'd leave the .htaccess file in place for all long as you have the website. That way anyone who still comes across an old URL will be able to find the new one easily and transparently.

  • This looks like a solid fix, however the structure of the site was drastically changed. I suppose, if I drop the $1 then it will forward to the domain rather then the domain+subdirectory as well? -- So then (./gallery/*) http://www.newdomain.com/ should work for all pages within gallery. Correct?
    – jbcurtin
    Commented Feb 14, 2011 at 15:18
  • Yes, but that will have very negative SEO effects for your site. Your best bet is to individually forward each page, and if that's too much to do, then forward the important pages and have any subpages forward to a"main" page that is related to it. Like all gallery pages can forward to the gallery home page.
    – John Conde
    Commented Feb 14, 2011 at 15:21
  • Is there a protocol I can use to tell google/bing in the html <meta> that said pages are depreciated and that it should look for new ones in a specific location? -- But I suppose that's what 301 is used for? I guess the question now is do most crawlers work this way.
    – jbcurtin
    Commented Feb 16, 2011 at 13:20
  • You can also take a look at Google Webmaster Tools, which won't o this for you, but will help you make sure everything is working properly. Commented Feb 22, 2011 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.