Redirecting "/" Root URL to Another Sub-Directory or URL

Posted: 2015-03-31 21:19:31

A typical redirect is usually done for either:

The limitation of Apache’s Redirect directive is that you cannot partially (nor selectively) redirect only the root URL “/”, without also redirecting everything after it to another path or location (e.g., redirect “/” will also match and redirect on request for “/folder/”)…

This is because Redirect matches everything after the given path, and a redirect from “/” is a redirection of all the website’s URLs.

Use RedirectMatch to only redirect the root URL “/” to another sub-directory or URL, without also redirecting everything else…

RedirectMatch ^/$

Since RedirectMatch uses a regex match, it can be specific with the “/” path without matching everything else.