How to Redirect Old Domain to New Domain Using htaccess Redirect
Posted on In WebI want to move the sub domain blog.pkill.info to systutorials.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 (.*) https://www.systutorials.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 ;)
Thanks for taking the time to post that. Worked for me!
Be sure your DB is backed up although this is usually a “safe” operation.
An alternative way is to use the Redirect if the Apache does not include the rewrite module: