Update old urls using 301 Redirect in .htaccess

If you are trying to redirect a URL and all its sub urls, so that http://olddomain/dishwasher-article redirects to http://newdomain.com/dishwasher-article , then keep reading!

What is .htaccess?

.htaccess file found in the root directory of sites is one powerful file. It can modify the functionality of the website. Having an approprtiate code that redirects websites accordingly can be superhelpful when you buy a new domain and don’t want to lose page rank, backlinks, and seo work done on the old domain, whether it be a free subdomain or a domain. The .htaccess redirect can be super useful if you are trying to redirect old links, got a new domain or migrated from an old host as it’ll send visitors to the old links to the new site without prompting them, annoying them or giving them any errors. Users like that alot and will come back and will note the url sooner or later.

It can be frustrating to get a working Rewrite rule. Half of them on the web don’t work, so after playing around I got the following to work and wanted to share with yall;

Open .htaccess and copy the following below

For subdomains

For domains

So that’s that, a quick write up, but hopefully very helpful.


  • http://stackoverflow.com/questions/9845098/how-can-i-301-redirect-specific-subdomain-urls-using-htaccess
  • http://stackoverflow.com/questions/5956844/how-to-redirect-a-url-by-only-changing-the-domain-name-while-keeping-other-url
Loading Facebook Comments ...

Leave a Reply

Your email address will not be published.

Loading Disqus Comments ...