When we restructure website url, sometimes we need to redirect url from sub folder to root folder [ public_html ].

This can be done in two ways using htaccess. Below methods redirect all http://example.com/blog/  requests to http://example.com/

Method 1:
Create a .htaccess file inside public_html folder and add the following:
RewriteEngine on
RewriteRule ^blog/(.*)$  /$1 [R=301,L]

( or )

Method 2:
Create .htaccess file inside public_html/blog and add the following:
RewriteEngine On
RewriteRule ^(.*)$  /$1 [R=301,L]


Comments (0)
Leave a Comment

loader Posting your comment...