gpt4 book ai didi

regex - %{REQUEST_URI} 总是以斜杠开头吗?

转载 作者:行者123 更新时间:2023-12-03 15:51:18 24 4
gpt4 key购买 nike

我已经在 2-3 个 apache 服务器上进行了测试,如果我没有出卖我的话,%{REQUEST_URI}总是以 / 开头,即使请求的 URL 是 http://domain.com (没有和结束斜线)。但是我已经看到 .htaccess 文件具有这样的规则:

RewriteRule ^[^/]*$ http...

我的意思是,这种规则会匹配 {REQUEST_URI}吗? ?或者我可能遗漏了一些关于 mod_rewrite 的东西( RewriteRule 之后的参数不是与 %{REQUEST_URI} 相同,因此不会发生匹配吗?)。

如果有人能就此启发我,将不胜感激。

最佳答案

RewriteRule模式不一定匹配 %{REQUEST_URI} .来自 the docs :

What is matched?

In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html").

In Directory and htaccess context, the Pattern will initially be matched against the filesystem path, after removing the prefix that led the server to the current RewriteRule (e.g. "app1/index.html" or "index.html" depending on where the directives are defined).



因为您在 htaccess 中看到了这些文件,要匹配的路径不会以 / 开头,因为删除的前缀将至少包含一个 / .

关于regex - %{REQUEST_URI} 总是以斜杠开头吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35320882/

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