The content of my site is located in www.example.com/main/
. I would like to use .htaccess
to redirect users from www.example.com
to www.example.com/main/
seamlessly, preferably so that URL remains www.example.com
despite this redirection.
I've looked at http://corz.org/serv/tricks/htaccess2.php 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.
I think one of these should work:
Here's a site that gives a simpler explanation: http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
And it's probably important to be good at regular expressions.
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?
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).