htaccess Rewrite Rule: Redirect to Index page from any subfolder

There have been always a requirement from the webmasters to redirect the user to a certain page from a particular folder at server level.

  • Certainly when some folders of the website are no more in use.
  • Infact created a new website in which some old website folders does not exist.

Now what to do?

  1. Simple create a new file and name it as “.htaccess” file
  2. Copy this file to the root directory of your website
  3. Place the following block of code in “.htaccess” file

RewriteEngine on
Redirect /SubFolderName/ /index.php

You are done. Please note that “.htaccess” file is supported by only Apache server.
For IIS server additional configuration is required to be done in IIS or need to install commercial available software which supports “.htaccess” file.

Bookmark and Share
Both comments and pings are currently closed.

One Response to “htaccess Rewrite Rule: Redirect to Index page from any subfolder”

  1. Chris Hlywa says:

    I love the valuable info you provide in your posts. I’ll bookmark your blog and check again here frequently. I’m fairly positive I’ll learn plenty of new stuff right here!

n