How to redirect from sub folder to root folder using htaccess
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:
( or )
Method 2:
Create .htaccess file inside public_html/blog and add the following:
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]
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]
RewriteRule ^(.*)$ /$1 [R=301,L]
Comments (0)