Bluehost使用指导:怎样将主域名绑定到二级目录

使用bluehost的同学都知道,我们网站所有的文件都是存放在Public_html目录的,主域名绑定的对应文件夹就是Public_html目录,addon domain绑定的域名就是Public_html的一个二级子目录,例如Public_html/youdomain.com,如果你想把主域名绑定到一个二级子目录,就需要通过.htaccess文件做一个转发。

  1. 登陆 Bluehost的cPanel控制面板
  2. 滑动到Files部分
  3. 选择File Manager图标
    bluehost file manage
  4. 勾选View Hidden Files(查看隐藏文件)
    bluehost file_manager_hidden_files
  5. 因为你要对Public_html文件夹进行操作,所以选择WebRoot (public_html/www)
    bluehost file manage
  6. 右键点击.htaccess文件,选择Code Editor
    bluehost文件
  7. 编辑.htaccess文件,插入如下代码,注意把example.com换成你自己的域名,把subdirectory换成你自己的目录名。

# Bluehost.com
# .htaccess main domain to subdirectory 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 example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change '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
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.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.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]

这样就把主域名绑定到了你自己设定的二级目录上,和绑定到Public_html主目录是一样的效果。

另外要注意有些网站程序,需要单独另外设置,具体方法点击下面的链接:

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注