网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   服务器环境搭建 (https://www.0058.net/forumdisplay.php?f=5)
-   -   .htaccess - How to make a subfolder the main folder for your main domain (https://www.0058.net/showthread.php?t=2740)

topvip 2007-08-21 11:08 PM

.htaccess - How to make a subfolder the main folder for your main domain
 
Problem:

The main domain on the hosting account uses the public_html folder for all of its Web site files. Any addon domains use subfolders inside the public_html folder. In order to also set up your main domain to use a subfolder on your hosting account you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subfolder on public_html.

Visitors to your Web site will not be able to tell that your main domain is using a subfolder, they will still see the Web site address as http://www.yourdomain.com/page.html


Solution:

# Hostmonster.com
# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.


# Do not change this line.

RewriteEngine on


# Change yourdomain.com to be your main domain.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$


# Change 'subfolder' to be the folder you will use for your main domain.

RewriteCond %{REQUEST_URI} !^/subfolder/

# Don't change this line.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.

RewriteRule ^(.*)$ /subfolder/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder 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.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]


All times are GMT +8. The time now is 10:44 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.