Code Food Travel repeat!

WordPress migration to new domain: Keep your SEO with these 301 Redirect Tips

Today I branched off to This is how I migrated one installation to another installation.

WordPress Migration

First, I transferred all my files using my web host ICDsoft‘s FTP migration tool.

Second, I used phpMyAdmin (on my web host ICDsoft‘s control panel) to download my MYSQL database files for my blog (all my blog entries and settings) to a zip file. I opened the zip file, and opened the database file with a text editor and did FIND AND REPLACE.
I found every entry for:
Replaced all instances with:

I saved file, and rezipped it. That way all my database links and files are updated and pointing to the right place. If you don’t update your urls, your wordpress login page will try to send you to your old website, and you’ll never get in!

Third, I created a new MYSQL database on my new site. I opened‘s copy of wp-config.php file and updated my MYSQL database name with what I just created, username, and password- so that it could connect.

Fourth, I logged into phpMyAdmin on and upload my modified database file. All done!

WordPress Redirect All URLs and images for Google with 301 Redirect

First I checked my new site to make sure everything worked properly. I saw that some of my theme settings were lost, but because I had the wordpress for open, I just manually copied/transcribed over each setting.

To redirect all my pages, I used this great tip from Schoonology:

Add this code to your functions.php file on your old blog, to tell it to redirect the base URL to your new site with the same page URL endings.

function conditional_redirect()<br>
			if ($_SERVER["SERVER_NAME"] != '')<br>
				wp_redirect('' . $_SERVER["REQUEST_URI"], 301);<br>
		add_action('get_header', conditional_redirect);<br>

From Schoonology: “the conditional checks to see if we’re already where we want to be. If we are, then there’s no reason to redirect someone to it, is there? Otherwise, perform the redirect.”

So that took care of all the URLS!

Redirect your wordpress images folder

Now for my uploaded wordpress images which are bringing me hits on google! To have these mirrored, I edited my OLD WEBSITE’s ( .htaccess file. NOT THE NEW ONE. I added one line of code inside the

&lt;IfModule mod_rewrite.c&gt;


The technique is called RedirectMatch with wildcards ^. You can google or see a more complicated example of it here.

This line will 301 Redirect the Entire Image Uploads Directory. note that the URL begins with /wp-content because I installed my wordpress in my main directory. (Note: If you stored yours in a folder, make sure to include that ie /blog/wp-content/…)

RedirectMatch 301 /wp-content/uploads/(.*) http://www.**YOURDOMAIN**.com/wp-content/uploads/$1<br>

This is my final htaccess file with the one line of code added:

# BEGIN WordPress<br>
&lt;IfModule mod_rewrite.c&gt;<br>
RewriteEngine On<br>
RewriteBase /<br>
RewriteRule ^index\.php$ - [L]<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]</p>
<p>RedirectMatch 301 /wp-content/uploads/(.*)$1</p>
<p># END WordPress<br>

Presto, URLs forward, and any images people try to access from google images etc gets instantly forwarded.
Google is all good to go! Hope this helps!!

About Steven Chu

Hi, I'm Steven! I'm an entrepreneur, photographer and art director in New York. Follow this blog for self expression, fun, and most importantly: looking comfortable, at ease, and amazing in your photos no matter who takes them! I dedicate this to my amazing friends who have let me inadvertently turn all of our hangouts and travel photos into a never ending photoshoot of fun. The proof is in the pudding-- our photos rock. My other projects: I'm the founder of, a face-to-face tech concierge service for NYC. Book a techie to walk you through something you want to learn! My work focuses on socially engaged art projects which use technology to create access to resources for communities. Visit Steven Chu Studio ( for branding & design work or Steven Chu ( for photography projects.

Leave a Reply

%d bloggers like this:
Read previous post:
Top New York Eats 2012

The Winners -FAVORITE RESTAURANTS- Find my favs on the food map below (designated by the SUN SYMBOL) Best American The...