Viewing entries in

How to Redirect all Wordpress links to a new domain name

Today I changed the name of my website from to I did not want to set up a new installation of Wordpress and import all of my old posts, rather I just wanted to change the name of my site. The problem is that I needed a way to have all of my old pages to redirect to the page. For example, should automatically send a visitor to I also wanted to make sure that search engines, like Google, knew that was no longer active and their results should be transferred to the equivalent page.

Changing the name of a Wordpress site

On your web host Make sure that the new domain name is linked to the directory containing your Wordpress site. In my case, both and pointed to the same directory. Using either your old or new domain name it should be possible to reach your site.

Redirecting links from the old domain to the new domain

To redirect all of you old links to the new site you must modify the .htaccess file in the root directory of your Wordpress install. If your web host has enabled "mod rewrite" capabilities, then all you need to do is add the following code before the Wordpress section of the file:

# Redirect the site 
RewriteEngine On 
# Take care of 
RewriteCond %{HTTP_HOST} ^$ [NC] 
RewriteRule ^(.*)$$1 [L,R=301]

# Takes care of 
RewriteCond %{HTTP_HOST} ^$ [NC] 
RewriteRule ^(.*)$$1 [L,R=301]

# Below is the standard code Wordpress uses 
# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
# END WordPress 

Change and to your old domain name, and to your new domain name. The first line of the code:

RewriteEngine On

enables the URL rewrite module that we need. The next line:

RewriteCond %{HTTP_HOST} ^$ [NC]

says that if anyone requests a page from then perform the rule on the next line. This rule is:

RewriteRule ^(.*)$$1

and it redirects the page to the equivalent page on The (.\*) means any text in the URL after, and the $1 at the end of is a variable that tells the web server to place the text from (.\*) after it. Now any website that calls a link like will now redirect to


The [L,R=301] at the end of the rule is a 301 redirect that tells any search engine or bookmark software that this is the new, permanent, home of the link and that they should update their records accordingly.

The next few lines are nearly the same and redirect all calls from to

Changing your site information in Wordpress

Once I verified that the redirects were working, I logged into my Wordpress admin panel and went to "Settings->General" where I entered in the new Site Name, Wordpress URL, and Site URL. Make sure you change change both the Wordpress URL and Site URL before saving. If you don't, this can cause an error. If things mess up, you can follow these instructions to fix things if you have FTP access to your site.

Alerting Google

I logged into Google Webmaster tools and Google Analytics and changed the name of my site from to All of my analytics and information smoothly transitioned over.

Following these steps it was relatively painless to rename my site without losing any of my old posts or creating duplicate content.