使用 htaccess 更改文档根目录 [英] Using htaccess to change document root

查看:30
本文介绍了使用 htaccess 更改文档根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站有文档根目录 ~/public_html 但我想将所有文件添加到 ~/public_html/www

My website has document root ~/public_html but i want to add all the files into ~/public_html/www

有没有办法用 htaccess 做到这一点?

Is there a way to do this with htaccess?

谢谢.

推荐答案

将以下行添加到 public_html 文件夹中的 .htaccess 文件:

add the following lines to the .htaccess file in the public_html folder:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]

这篇关于使用 htaccess 更改文档根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆