Quantcast
Channel: DeveloperSide.NET » WAMP Developer Server
Viewing all articles
Browse latest Browse all 108

How to Redirect “/” Root URL to Another Sub-Directory or URL

$
0
0

A typical redirect is usually done from either:

  1. The entire website to another website:
    Redirect / https://www.example.com/
  2. Or from one specific path of a website to another location:
    Redirect /path http://www.example.com/someother/path

The limitation of Apache’s Redirect directive is that you cannot redirect just the root URL “/”, and nothing after it, to another path or location. As Redirect matches everything after the given path, whatever follows it, and a redirect from “/” is a redirect of all the website’s URLs.

Use RedirectMatch to redirect the root URL “/” to another sub-directory or URL…

RedirectMatch ^/$ http://www.example.com/another/path

Since RedirectMatch uses a regex, it can be specific with the “/” path without matching anything more.


Viewing all articles
Browse latest Browse all 108

Trending Articles