Learn how to redirect your visitors to a sub-folder that’s two levels deep from the root directory.
For example www.RootDir.com/SubFolderA/SubFolderB.
Let’s say users arrive at SubFolderA and you want to redirect them to SubFolderB.
RedirectMatch ^/SubFolderA/?$ /SubFolderA/SubFolderB/
Place the .htaccess file with the above line in the root directory of the domain.
What Does it Mean?
Apache provides two modules for redirecting stuff with .htaccess: mod_alias and mod_rewrite. RedirectMatch falls under the module mod_alias.
- ^ Denotes the beginning of a regular expression
- $ Denotes the end of a regular expression
- ? Declares the preceding character “/” (forward slash) is optional