Apache2 Redirect to Subdirectory – How to Configure

.htaccessapache-2.2redirect

I am running apache2 on Debian etch, with multiple virtual hosts.

I want to redirect so that http://git.example.com goes to http://git.example.com/git/

Should be really simple, but Google isn't quite cutting it. I've tried the Redirect and Rewrite stuff and they don't quite seem to do what I want …

Best Answer

Feel a bit silly - a bit more googling turned up the answer I was after:

RedirectMatch ^/$ /git/

Basically redirecting the root, and only the root.

This code could do in a .htaccess file (there is a tag for this, so I assume that is the original use case). But if you can edit ,the main server apache config then put it in the section for your website probably inside a <VirtualHost> section.

The docs for RedirectMatch say that the context can be "server config, virtual host, directory, .htaccess".