About 1 month ago, I did the unthinkable: I took a successful website I had developed, and I completely re-branded it to a new domain name. The reasons I wanted to re-brand the site can be summarized below:
- I wanted the name to reflect the actual disorder. This just looked more professional than “heat hives.” This was important since I wanted this to be the number 1 site about this condition on the entire web.
- I theorized that if the domain name matched my actual keywords for the site, I would see a bump in SEO benefits.
So I researched to how completely change your WordPress blog (and forum software) to a new domain name. It actually wasn’t difficult (I will post on this soon too). The whole process took about a day.
To do this, you will need to create a list of all of your old URLs and all new URLs so that you can use the redirect code (below) to redirect all old URLs to the new ones. So if you have hundreds or thousands of pages, you will need hundreds or thousands of redirects. You then add this list of redirect codes to your .hta access file on your server (for the old domain). This will also transfer PageRank (although it will take a few weeks/months for that). The redirect code you will need to use for each individual URL is below (1 URL example):
redirect 301 /your-old-url/ http://www.new-domain.com/your-old-url/
As you can see, the first part of the URL just contains the redirect code (redirect 301) which means it is a permanent redirect. Next, you have the extension of the old domain’s file. So if it was: example.com/your-old-url/, the first part of the code would be /your-old-url/.
The next part contains the full URL for the redirect. This URL should contain the new domain name (and the file extension will be the same unless you rename the file).
But anyway, here is how I setup a 301 Redirect to a new domain easily with an entire list of redirects:
How to Setup a 301 Redirects for Each URL When Changing a Blog or Website’s Domain Name
First, always use common sense and make backups of everything before you change anything just in case something goes wrong. Better safe than sorry! Now you can get to creating your 301 redirect list.
1. Copy All URL’s Before Changing–You need to make a list of all of your URLs before making the move and creating your 301 redirect. For mine, I copied this list into notepad. This is easy if you have a WordPress sitemap.xml plugin. I just went and copied all of the URLs from my sitemap.xml file. If you don’t have this, you need some way to get the complete list of all of your URL’s. You only need the URL at this point, and nothing else (if your sitemap has other data). Don’t forget to include EVERY page you want redirected. The list looked something like this in my blank notepad file (2 URL example out of hundreds):
NOTEPAD FILE #1
yourdomain.com/example/ newdomain.com/forum/
2. Make A Second Copy of the Old URL’s–I then opened another notepad file, and I copied & pasted all of the old URL’s from the first list (NOTEPAD FILE #1) into it the new notepad file (NOTEPAD FILE #2). So at this point I have 2 notepad files with an identical list of the old domain’s URL (all in the same order, same spacing–that is important).
3. Use Find and Replace on the Second List–On the NOTEPAD FILE #2 list I created in the step above, I used the “find and replace” feature (under the edit menu on notepad), and I replaced all of the “example.com” occurrences with “newdomain.com.” This was super easy and worked instantly. Thus, I now had 2 lists in 2 different notepad windows: One with the old URL’s, and one with the new URL’s (the domain was all that needed updating).
So NOTEPAD FILE #1 still looked like the list in number 1, and the NOTEPAD FILE #2 was changed (by using find and replace) to reflect the new domain URLs, and it looked like this (make sure to put the http part in front of it when you do it):
yourdomain.net/example/ newdomain.com/forum/
4. Edit NOTEPAD FILE #1 to Match the Beginning Redirect Code–At this point in time, we need to change the old URLs to match the beginning of the redirect code. Thankfully, we can use find and replace again. So I went to NOTEPAD FILE #1, which looked like this:
example.com/example/ newdomain.com/forum/
and I used search/find and replace to edit the file again. For the “find” part, I entered: http://www.heathives.com and for the “replace” section I entered: redirect 301 (with a space after the 301). This made the NOTEPAD FILE #1 look like this:
redirect 301 /example/ redirect 301 /forum/
5. Copy Each List into a Column in Excel or Calc–At this point we are getting close to having our completed file for the 301 redirect. We still need to connect what is in NOTEPAD File 1 to what is in NOTEPAD file 2 on one line so we can have the completed redirect code for each individual URL. We need this for EVERY URL we have in order for it to work right!
So how I did this was I copied all of the contents in NOTEPAD 1 into column A of a spreadsheet. I then copied the contents of NOTEPAD #2 into column B. Make sure each one lines up perfectly as the example shows below:
Column A: Column B:
redirect 301 /example/ newdomain.com/example/
After each notepad file was posted in the appropriate column, I then merged each row (merging column A & B only), so that it all came together like this:
redirect 301 /example/ http://newdomain.com/example/
Next, I recopied all of the finished code into notepad, and made sure it looked great. Make sure the code has the appropriate spaces, and only one redirect is present per line (although if you have long URLs it may take up two lines for each code). The finished product should look like this in notepad (only 2 URL’s used as an example):
redirect 301 /example/ newdomain.com/example/ redirect 301 /forum/ newdomain.com/forum/
So make sure each line has appropriate format, single spaced, one space after the old URL and new.
Uploading the 301 Redirect Code to Your Blog or Website’s .HTA File
You then need to edit the .hta file on your server. IMPORTANT: The 301 redirects need to go on the OLD domain .hta file (not the new one). This should be in the root directory of your old domain’s files. It just says .hta. In Godaddy.com, this is easy to edit. Just select the file, and hit the edit button. This will then open the file.
I then copied and pasted all of the finished URL redirect codes from my notepad file into the .hta file. There were several hundred URLs, so it was quite long. I then saved the .hta file.
Next, I checked to make sure it was properly redirecting to the new site. Just enter the old URL into a browser, and it should immediately redirect you to the same file on the new domain name. It worked like a charm.
Also, you need to keep the old domain and the .hta access file intact for as long as you want to redirect (which is potentially forever). So make sure to renew the old domain so you can get all of the old referring traffic (from old links/bookmarks) and so it will redirect properly to your new domain.
Final Thoughts and Tips:
This worked great for me, and only took about an hour or so. It is far easier than doing each URL manually. Here are a few other comments about this experience:
- It took the search engines about 2-5 days to update the search results to the new URLs. So keep that in mind.
- I did not see any drop in traffic at all. So that was worth the effort alone, and I highly recommend you do this for you visitors and good webmaster practices.
- This only works on Apache servers (or servers configured to recognize the redirect code)
- Your server must have rewrites available. It should automatically be set up for this if you are using Wordrpess.
- PageRank WILL update to the new domain & pages if you do this right. However, it does take a bit longer (usually a few weeks-3 months)
- Google Webmaster tools also has a neat feature where you can do a “Change of Address.” I also did this to help speed the process.
- I did see an SEO benefit by having my main target keyword in my domain. This took place within a week or two (before the actual PageRank Updated)
- You need to update any links outside of your site (I will cover that in a future post). Also, you need to do it within your site.
- There may be an easier way to update all URLs and create a redirect other than what I have posted above. If there is, I couldn’t find it. I invented this method of combining the URLs in notepad myself, and it was fairly quick. It would be nice if one line of code could do this without having to list individual URLs. But to my knowledge, it doesn’t work. If you know an easier way of doing this without having to create individual redirects for every page, write a post about it and ping this article. I will be happy to add a link if you can do it better.
- This took place in early 2010. So if you are reading this article in year 2075, this page will be probably completely irrelevant and outdated. But this should do the trick for now.
I hoped that helps anyone changing their blogs or websites to a new domain. It may take an hour or two for you to do this, but it is worth it.