php加载同级目录,php – 从根目录加载.htaccess

所以我创建了一个跨多个站点相同的模板系统,唯一改变的是配置文件.我正在制作所有文件都是从根目录中获取的.我可以使用我的所有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

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文件夹,依此类推.

标签:apache,php,htaccess

来源: https://codeday.me/bug/20190611/1221687.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值