这个 .htaccess 代码是什么意思?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php
我认为这意味着如果 url 与服务器上的文件或目录不匹配,请转到 /index.php?
有人可以确认吗?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php
I think it means if the url doesn't match a file or directory on the server go to /index.php?
Can anybody confirm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是简短的答案。但通常
./index.php
具有[L,QSA]
后缀/限定符,因此 URI 请求的查询部分也会传递给它。Yes is the short answer. But usually
./index.php
has an[L,QSA]
suffix/qualifier, so the query part of a URI request is also passed on to it.这是在做什么:
如果找不到该名称的目录
如果找不到该名称的文件
加载.htaccess 文件旁边的index.php。
回答安东尼关于如果删除它会发生什么的问题1 2 ,
它会尝试访问目录或文件。如果失败,它不会默认使用
index.php
,而是简单地给出默认 Web 服务器 404 错误。现在,它允许应用程序显示默认页面,或通过它以某种方式处理请求。
What this is doing:
If it can't find a directory with the name
If it can't find a file with the name
Load the index.php next to the .htaccess file.
To answer Anthony's question regarding what would happen if it where removed1 2,
It would try and access the directory or file. If it fails, instead of defaulting to the
index.php
it would simply give the default web servers 404 error.Right now, it allows the application to either show the default page, or handle the request through it in some fashion.