Changing the top level directory with .htaccess files
When our Web servers receive a request for “http://www.example.com/” or “http://example.com/”, they show the index file from the top level directory of your Web site.
Occasionally, people want to use a different directory as the top level. For example, you might want the contents of your “blog” folder to show as the main page.
The simplest way to do that is to move the contents of the “blog” directory to the top level. That’s the way we recommend doing it.
Changing how the Web server handles the top level
If you can’t move the files for some reason, technically advanced customers can use a .htaccess file to “rewrite” the top level requests. (We don’t recommend this for most customers.)
This .htaccess example shows how to make a directory named “subdir” act as the top level:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteRule ^(.*) /subdir/$1 [L]
The “RewriteCond” line is crucial: it makes sure that any existing URLs that begin with “/subdir” continue to work, and more importantly, it prevents an infinite loop of rewriting.
The example above will modify requests for any page that doesn’t already begin with “/subdir/”. If you have other existing directories that need to keep working, you can include those as additional directories to leave alone. This example will also allow URLs beginning with “/archives” and “/images” to keep working without any rewriting:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_URI} !^/archives/
RewriteCond %{REQUEST_URI} !^/images/
RewriteRule ^(.*) /subdir/$1 [L]
A caveat about “favicon.ico” files
Due to a technical quirk, this won’t correctly use a “favicon.ico” file in your special directory if there’s no “favicon.ico” at the top level, too. To avoid this problem, just make sure there’s a file named “favicon.ico” at the top level of the site (the contents don’t matter and won’t actually be used).
Need help?
If you’re having trouble, contact us with the details of what you want to do. We’ll be glad to help you find the best solution for your situation.
