Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 ...

share|improve this question
There are many ways you could approach this, but what is exactly what you are trying to accomplish? –  WerkkreW May 19 '09 at 17:24

4 Answers 4

You can use Redirect directive.

<Directory />
   Redirect permanent / http://git.example.com/git/
share|improve this answer

You've got the correct answer there with the redirect. You have to be careful when redirecting everything to somewhere else, since you can get recursive redirects there. This happens if you want to put up a maintenance page.

share|improve this answer

On my own website, I used a 301 redirect by placing the following in index.php in the root directory:

// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://git.example.com/git/");
share|improve this answer
That works, but using PHP just to do a redirect is overkill (and not as efficient as Apache directives). –  David Z May 20 '09 at 5:07
up vote 28 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.