加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 从根目录加载.htaccess

发布时间:2020-12-13 17:49:15 所属栏目:PHP教程 来源:网络整理
导读:所以我创建了一个跨多个站点相同的模板系统,唯一改变的是配置文件.我正在制作所有文件都是从根目录中获取的.我可以使用我的所有php和html文件来完成它,但我无法在我的.htaccess文件中找到它.如何设置目录是/ home / user_name / template,然后还有/home/user
所以我创建了一个跨多个站点相同的模板系统,唯一改变的是配置文件.我正在制作所有文件都是从根目录中获取的.我可以使用我的所有php和html文件来完成它,但我无法在我的.htaccess文件中找到它.如何设置目录是/ home / user_name / template,然后还有/home/user_name/site1.com等文件夹以及所有站点外的文件夹.那么我怎么能让所有网站使用相同的.htaccess文件.我希望这是有道理的!

解决方法

根据维基百科

A .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers,that allows for decentralized management of web server configuration. They are placed inside the web tree,and are able to override a subset of the server’s global configuration for the directory that they are in,and all sub-directories

从Oracle-Docs开始:

If you enable .htaccess files,the server checks for .htaccess files before serving resources. The server looks for .htaccess files in the same directory as the resource and in that directory’s parent directories,up to and including the document root.

例如,

如果主文档目录设置为/ oracle / server / docs

和a

客户请求/oracle/server/docs/reports/index.html,

服务器将检查:

.htaccess files at /oracle/server/docs/reports/.htaccess and /oracle/server/docs/.htaccess.

假设您有2个站点,并且您希望使用单个文件为两个站点设置.htaccess

然后只需创建如下的文件结构

>父母

> site1
> site2
> .htaccess

这里将site1的所有数据上传到site1文件夹,依此类推.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读