Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The content of my site is located in I would like to use .htaccess to redirect users from to seamlessly, preferably so that URL remains despite this redirection.

I've looked at but I can't seem to figure out how to make this simple redirect. What do I need to do to make this work? Also, can you point me to a resource you've used to learn .htacess rules? I would like to learn them for the future.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

I think one of these should work:

RewriteRule ^/?$ /main [L]

RewriteRule ^$ /main [L]

RewriteRule ^/$ /main [L]

Here's a site that gives a simpler explanation:

And it's probably important to be good at regular expressions.

share|improve this answer
Actually the first two versions both work--it is possible to modify them so that the URL stays cloaked to just – Oren Hizkiya Sep 13 '10 at 5:51

You can't do this with .htaccess (at least I don't think you can) - you can't rewrite the domain without rewriting it in the address bar. Do it with an iframe inside index.html, or index.php, or be really hacky with unpredictable results and symlink it.

In fact, why not move /main/ to / and then rewrite /main/ back to / - or does that not fit in with your plans?

share|improve this answer
Yea, due to the way things are configured that isn't an option now – Oren Hizkiya Sep 13 '10 at 15:46

You can have the url to remain the same just do as 'jkeesh' said but append a / after main.

RewriteRule ^$ /main/ [L]

Also consider not using .htaccess as it has performance impact and try using httpd.conf instead and mod_alias is better for this purpose as well(cannot be used in .htaccess).

share|improve this answer
What you suggested works, the problem is that then all of the links are broken because they are relative to /main/ - I'm on a cheap host for the moment so httpd.conf and mod_alias aren't an option. – Oren Hizkiya Sep 13 '10 at 13:10

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.