这个重写规则是什么意思?
我正在安装 phpancake, 有一个像这样的文件夹 shema
application/
install/
library/
public/
sql_schema/
install.html
install.php
这条规则是什么意思?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /vote/public/index.php [NC,L]
Im installing phpancake,
there is a folder there shema like this
application/
install/
library/
public/
sql_schema/
install.html
install.php
What does this rule mean?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /vote/public/index.php [NC,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
重写有两个部分。第一个指定如果请求的文件名是大小大于 0 的常规文件 (
-s
)、符号链接 (-l
) 或目录 (< code>-d),重写到任何地方,例如。不采取任何行动。[NC,L]
表示该规则不区分大小写,并且是这些条件匹配的最后一条规则。所有其他请求都会转发到
/vote/public/index.php
。此重写的目的是可以不受干扰地从服务器获取实际的现有文件。如果没有第一条规则,每个文件请求(css 和 js 文件、图像等)都会发送到
index.php
,这会让事情变得非常糟糕。不过,通常这会写在一份声明中。你可以否定条件,然后也可以去掉
[OR]
语句:这与原来的语句是等价的。
The rewrite has two parts. The first one specifies that if the requested filename is a regular file with a size greater than 0 (
-s
), a symbolic link (-l
) or a directory (-d
), rewrite to nowhere, eg. take no action.[NC,L]
means that the rule is non case sensitive and the last rule that these conditions match.All other requests are forwarded to
/vote/public/index.php
.The purpose of this rewrite is that an actual, existing file can be fetched from the server without interference. Without the first rule, every file request (css and js files, images etc) would go to
index.php
which would mess things up pretty badly.Usually this is written in one declaration, though. You can negate the conditions, and then the
[OR]
statemens can be taken out also:This is equivalent to the original statement.
这些主要是标准重写,检查磁盘上是否存在请求的文件(或目录或符号链接),在这种情况下,文件/目录/等。应该使用。
所有其他匹配应转到 /votes/public/index.php
Those are mainly standard rewrites which check if the requested file (or directory or symbolic link) exists on disk, in which case the file/directory/etc. should be used.
All other matches should go to /votes/public/index.php
第一个规则将传递所有可以映射到大小大于零 (
-s
)、符号链接 (-l
) 或目录(-d
)。所有其他请求均由第二条规则获取并重写到/vote/public/index.php。The first rule will pass through all requests that can be mapped to a regular file with a size greater than zero (
-s
), a symbolic link (-l
) or a directory (-d
). Every other request is fetched by the second rule and rewritten to /vote/public/index.php.