Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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
add comment

4 Answers

up vote 23 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
add comment

You can use Redirect directive.

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

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
add comment

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

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://git.example.com/git/");
exit();
?>
share|improve this answer
3  
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
add comment

Your Answer

 
discard

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.