gpt4 book ai didi

regex - RewriteRule ^(.*)/$ ?path=$1 [QSA,L] 在我的 .htaccess 中是什么意思?

转载 作者:行者123 更新时间:2023-12-01 09:27:45 28 4
gpt4 key购买 nike

我需要在 nginx 中创建重写,就像在我的 .htaccess 中所做的那样,有些行我不完全理解。

DirectoryIndex index.php

RewriteEngine on
RewriteCond % !-f
RewriteRule ^(.*)/$ ?path=$1 [QSA,L]

谁能给我解释一下?

最佳答案

RewriteCond % !-f 似乎不正确的规则条件并且总是评估为真。

这条规则:

RewriteRule ^(.*)/$ ?path=$1  [QSA,L]

是否匹配任何带有斜杠的 URI 并在内部重写为 /?path=uri-without-slash

例如:URI /foo/ 将被重写为 /?path=foo

  • QSA - 查询字符串追加
  • L = 最后一条规则

引用:Apache mod_rewrite Introduction

更新:将不正确的条件更改为:

# 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]

关于regex - RewriteRule ^(.*)/$ ?path=$1 [QSA,L] 在我的 .htaccess 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20260571/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com