这个重写规则是什么意思?

发布于 2024-08-18 05:03:29 字数 393 浏览 5 评论 0原文

我正在安装 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野心澎湃 2024-08-25 05:03:29

重写有两个部分。第一个指定如果请求的文件名是大小大于 0 的常规文件 (-s)、符号链接 (-l) 或目录 (< code>-d),重写到任何地方,例如。不采取任何行动。 [NC,L] 表示该规则不区分大小写,并且是这些条件匹配的最后一条规则。

所有其他请求都会转发到 /vote/public/index.php

此重写的目的是可以不受干扰地从服务器获取实际的现有文件。如果没有第一条规则,每个文件请求(css 和 js 文件、图像等)都会发送到 index.php ,这会让事情变得非常糟糕。

不过,通常这会写在一份声明中。你可以否定条件,然后也可以去掉[OR]语句:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /vote/public/index.php [NC,L]

这与原来的语句是等价的。

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:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /vote/public/index.php [NC,L]

This is equivalent to the original statement.

浴红衣 2024-08-25 05:03:29

这些主要是标准重写,检查磁盘上是否存在请求的文件(或目录或符号链接),在这种情况下,文件/目录/等。应该使用。

所有其他匹配应转到 /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

沫尐诺 2024-08-25 05:03:29

第一个规则将传递所有可以映射到大小大于零 (-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文