Moving a WordPress-powered site to another domain: The Permalink

Yesterday, I needed to move a self-hosted WordPress site to another domain. The process was easy because it’s like copying all files, edit the configuration file and editing internal links in all posts. All process only took less than 15 minutes. But, that’s not the only thing. One of the important things needed is to maintain the article links — known as “permanent link”.
This is important because I don’t want to send the visitors coming from other sources (links in blog posts, shared link on Twitter or Facebook) to missing pages. It’s called “permanent link”, right? So, having the permanent link broken is not a good idea.
I came up with a simple solution: using .htacess. After moving all files and checking all configurations I put these lines in the .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

So, when visitors visit olddomain.com/path/to/article/, the browsers will go automatically to newdomain.com/path/to/article/. Easy!


Comments

One response to “Moving a WordPress-powered site to another domain: The Permalink”

  1. Yah, telat mendapat infonya, kemarin terpaksa ribet2 deh :D