[英].htaccess DirectoryIndex /subfolder/index.php seems to manage links in a funny way
I have the default myIndex.php in a subfolder of public_html. 我在public_html的子文件夹中有默认的myIndex.php。
I added a file .htaccess in public_html. 我在public_html中添加了文件.htaccess。
I added DirectoryIndex /subfolder/myIndex.php in it. 我在其中添加了DirectoryIndex /subfolder/myIndex.php。
myIndex.php contains links and includes. myIndex.php包含链接并包含。 Includes seems to work but links dont: no images and no css but menu.php is included. 包括似乎工作,但链接不起作用:没有图像,没有CSS,但包括menu.php。 Links in menu.php dont work either. menu.php中的链接也不起作用。
If I 如果我
change .htaccess to DirectoryIndex index.php, 将.htaccess更改为DirectoryIndex index.php,
create a file index.php in public_html, 在public_html中创建文件index.php,
and put a link to "./subfolder/myIndex.php" in it 并在其中放置一个指向“ ./subfolder/myIndex.php”的链接
everything works fine. 一切正常。
I dont understand what happens here. 我不明白这里会发生什么。
DirectoryIndex
determines what to do, when a client requests a directory. DirectoryIndex
确定客户端请求目录时的处理方式。 If you have 如果你有
DirectoryIndex /subfolder/myIndex.php
then exactly this script will be executed every time the client requests a directory, no matter where this directory is, eg /anotherfolder/
or /static/
. 那么无论客户端位于哪个目录(例如/anotherfolder/
或/static/
),每次客户端请求目录时都将准确执行此脚本。 But when you have 但是当你有
DirectoryIndex index.php
instead, Apache looks for an index.php
in the requested directory, eg /anotherfolder/index.php
or /static/index.php
. 相反,Apache在请求的目录中查找index.php
,例如/anotherfolder/index.php
或/static/index.php
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.