How to move WordPress without breaking web links

WordPress allows you to specify your blog url as, for example, www.ipreferjim.com/site. It also allows you to run the blog from the base of your domain, e.g. www.ipreferjim.com. For the longest time, I didn’t mess around with this because I didn’t see it as a big deal.

Not long ago, I upgraded linux hosting to Windows deluxe hosting at Godaddy.com. There were so many issues with WordPress under windows (see my previous post). On top of that, performance had never been exactly what I’d expect, and a lot of constraints were blocking me from being productive. So, I switched to hostgator.com.

The problem is that I have years of links to my site in the format:


http://www.ipreferjim.com/site/2011/06/godaddy-url-rewrite-fix-for-directory-without-trailing-slash/

and I now wanted it in the format:


http://www.ipreferjim.com/2011/06/godaddy-url-rewrite-fix-for-directory-without-trailing-slash/

I went about this by following WordPress’s guide to giving wordpress its own directory. This went well, then I had to update the .htaccess file to allow /site/wp-admin yet remove /site from all other links.

# BEGIN WordPress

RewriteEngine On
RewriteBase /site
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]

RewriteRule ^/site/wp-admin(.*)$ /site/wp-admin/$1 [L]

# END WordPress

flattr this!