我需要在 nginx 中创建重写,就像在我的 .htaccess 中所做的那样,并且有一些行我不完全理解。
DirectoryIndex index.php
RewriteEngine on
RewriteCond % !-f
RewriteRule ^(.*)/$ ?path=$1 [QSA,L]
有人可以向我解释一下吗?
RewriteCond % !-f
规则条件似乎不正确,并且始终评估为 true。
这条规则:
RewriteRule ^(.*)/$ ?path=$1 [QSA,L]
Is 匹配任何带有斜杠的 URI并在内部重写为/?path=uri-without-slash
例如:一个 URI/foo/
将被重写为/?path=foo
参考:Apache mod_rewrite简介 http://httpd.apache.org/docs/current/rewrite/intro.html
UPDATE:将不正确的条件更改为:
# request is not for a file
RewriteCond %{REQUEST_FILENAME} !-f
# request is not for a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ ?path=$1 [QSA,L]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)