Tuesday, June 4, 2013

Redirect directory to root .htaccess

Simple of the things sometimes waste too much time. Recently I needed this simple htaccess script to direct one of the subdirectory to the root. I needed same url other than the directory part.

This htaccess code did it for me

RewriteEngine On
RewriteBase /
# redirect stores to root
RewriteRule ^stores/(.*)$ /$1 [R=301,NC,L]

This code redirected all the content of the stores directory to root directory.

I placed this code in the root htaccess and removed the htaccess file from stores directory.

No comments:

Post a Comment