`
xinlanzero
  • 浏览: 245818 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Bluehost 主域名映射到子目录文件夹的方法 .htaccess

 
阅读更多

在bluehost上购买了空间,如何让一个主域名访问子目录呢,最简单方法是用 .htaccess 来进行限制。

在bluehost 的/public_html 新建立一个 .htaccess 文件,如果没有这个文件的话。

拷贝下面代码放到 .htaccess 文件里

# 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 yourdomain.com to be your main domain. 添加你的主域名
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this 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 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.)?yourmaindomain.com$
RewriteRule ^(/)?$ subdirectory/index.php [L]

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics