How to redirect folder to another directory using htaccess

Some times you want to redirect not only one page, but an entire folder from your website to anther, in this case it does not make sense to redirect each page in the folder, because if this solution worked with a folder or directory of 10 pages, it will not be fine for anther one with has 1000 page for example.

In the following lines we will see how to do it, suppose we have to folders or directories directory1 and directory2, the following code is a mod rewrite to redirect directory1 to directory2.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^directory1/(.*)$ /directory2 [R=301,L]
</IfModule>

Just copy these lines to your htaccess file and every thing will work for you.

Related Posts
Comments
  1. No comments yet!, be the first to post a comment.

Your email will not be published, The required fields marked with '*'

*