html怎么设置子目录,如何让主域名指向public_html下的子目录

791c70e2fb7dcbc6f828b86f98643973.png

遇到很多用户反应主域名到子目录不管用问题,大部分是主机商不支持,没办法国内的主机商黑心太多,推荐大家使用hostease,笔者使用多年hostease,发现hostease技术实力还是相当的不错的。使用的cpanel面板,非常不错。对于主域名指向子目录问题,只要简单几个点击就能完成

编辑public_html目录下的.htaccess文件,加入如下语句.如果public_html下没有.htaccess文件,新建一个即可.

注意:将 yourmaindomain.com修改为你的域名,将subfolder修改为你要指向的public_html下的子目录.最后一行中的index.php修改为你的网站的主页名称.(修改粗体表示的内容,其他内容不要改动)

# www.host114.org

# .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.

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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值