- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
%{REQUEST_FILENAME} 和 %{THE_REQUEST} 返回什么?
我只是在检查我们的 .htaccess 文件,我突然明白了,我对此知之甚少。下面的代码同时使用了两者。它有效,我只是想了解它。
#remove / at the end of URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/$ /$1 [L,R=301]
#remove /index.php at the end of URL
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
最佳答案
感谢艾哈迈德提供 the link .
作为对懒得点击它的任何人的快速引用,这是我所追求的...
THE_REQUEST The full HTTP request line sent by the browser to the server (e.g., "GET /index.html HTTP/1.1"). This does not include any additional headers sent by the browser. This value has not been unescaped (decoded), unlike most other variables below.
REQUEST_URI The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as as its own variable named QUERY_STRING.
REQUEST_FILENAME The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI. Depending on the value of AcceptPathInfo, the server may have only used some leading components of the REQUEST_URI to map the request to a file.
关于.htaccess - 什么是 .htaccess 元素 REQUEST_FILENAME 和 THE_REQUEST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17211802/
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\]*)?\HTTP/ 除了以下部分,我理解上面一行中的所有内容: ([#?][^\]*)?\HTTP/ 我做了
%{REQUEST_FILENAME} 和 %{THE_REQUEST} 返回什么? 我只是在检查我们的 .htaccess 文件,我突然明白了,我对此知之甚少。下面的代码同时使用了两者。它有效,我只
我正在试验 mod-rewrite。我以为我想要的很简单,但我没有通过 REQUEST_URI 获得请求的文件的 URI。而是传递传递的名称。 manual说: THE_REQUEST The ful
我是一名优秀的程序员,十分优秀!