Sunday, 5 August 2018

Add URL redirection or 301 Redirect through .htaccess file

To add URL redirection from old to new URL you can add by using the below mentioned code;

Redirect 301 old_URL new_URL

Here "old_URL" means relative path for example your old URL was something like: www.example.com/about/ so you have to write only "/about/" do not include full url path and always exclude domain name in the URL.

And "new_URL" to have to mention full path/absolute part like "www.example.com/about-us/"

You can find the .htaccess file in WordPress root folder directory (Or project root folder) or create there if not present.

Example:
old_URL: http://www.wordpresslocal.com/about-old/
new_URL: http://www.wordpresslocal.com/about-us/

Code which need to add in .htaccess file is:

Redirect 301 /about-old/ http://www.wordpresslocal.com/about-us/


Below is the video demonstration for above mentioned points.




Version at the time of demonstration
1) WordPress: 4.9.8
2) Localserver: XAMPP Control Panel v3.2.2
3) Visual Studio Code v1.25
Load disqus comments

1 comments: