How to Redirect Old Domain to New Domain Using htaccess Redirect

I want to move the sub domain blog.pkill.info to fclose.com permanently. I can manage all the pages I want to post using WordPress. Changing domain in a bad way is dangerous. Put a page the tell the reader that the site is moved to a new domain is very unfriendly to the user and also the search engine. When I moving my blog two my own domain from HKUST’s iblog, I found most of the readers don’t try to search and find the pages that interest them in the new domain especially when they find the old site by a search engine.

301 Redirect

301 redirect is the most Reader Friendly and Search Engine Friendly method for webpage redirection. The user can get the same page even if they use the old URL. The browser will automatically redirect them to the new address of this page. Of course the URL structure except the domain should keep the same. And the 303 redirect method should preserve the search engine rankings for that particular page. The code “301” is interpreted as “moved permanently”.

.htaccess redirect

The .htaccess method of redirection only works when the server is Apache and the Apache Mod-Rewite module is enabled.

Create a .htaccess file in the root directory of the old domain (blog.pkill.info in this example). Then add the below code the .htaccess file:

# BEGIN Redirect
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://fclose.com/$1 [R=301,L]
</IfModule>

# END Redirect

With the above code, it will be ensured that all the directories and pages of the old domain (blog.pkill.info) will get correctly redirected to the new domain. The domain part can be changed to any domain that is needed.

For WordPress, changing the application files is not enough. The domain name has also been stored in the database so the site owner should also change the entries that store the domain name in the database using some tools like phpMyAdmin. There are two entries should be changed in the table wp_options. Just find the two entries whose value is the old domain and change it to the new domain. Then the new domain will be in service now ;)

Eric Zhiqiang Ma

Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

5 comments:

Leave a Reply

Your email address will not be published. Required fields are marked *