Point your home page URL to a subdirectory

Method 1 - Redirect your main domain to a subfolder on that domain:

RewriteEngine On
# Change YourDomain.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain
RewriteRule ^(/)?$ subdirectory [L]

Method 2 -  Show the content of a subdirectory while you are on your main domain:


RewriteEngine on
# Change YourDomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change YourDomain.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Do you support mod_rewrite for apache?

Yes, mod_rewrite is enabled on your server. For more information on what mod_rewrite is and how...

How to execute php code as .htm or .html files

In your .htaccess file insert this line of code. addhandler application/x-httpd-php .htm .html

Disabling Magic Quotes GPC

How to turn off magic quotes gpc (required by Joomla 3 and some other scripts).1. Create a...

Block Bad Bots and Spiders using .htaccess

Below is a useful code block for blocking a lot of the known bad bots and site rippers currently...

.htaccess RewriteRule Examples

Here are some useful mod_rewrite RewriteRule redirect examples that you can use in your .htaccess...