Loading your main website from a subdirectory Print

  • 0

By placing the following code in your .htaccess file  in your main public_html you can load your main site from a subdirectory:

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

You will need to edit the entries as shown in the comments above.

 


Was this answer helpful?

« Back