这个 Mod 重写有什么作用?
谁能告诉我这是做什么的?
RewriteRule .* .main.php [QSA,L]
据我了解,它会将任何内容重写到 main.php ,正确吗?但不太确定 QSA,L 是做什么的。
这是整个 .htaccess 文件,当我进入主目录时,我收到 400 Bad Request 错误。 编辑:当我在浏览器中添加结束斜杠到该脚本的根目录时,错误的请求消失了。
RewriteEngine On
# Transfering to the main tranfer file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !\.css$
RewriteCond %{REQUEST_FILENAME} !\.js$
RewriteRule .* .main.php [QSA,L]
# nobody is allowed to access the access the INI file
<FilesMatch "\.inc.php$">
Order allow,deny
Deny from all
</FilesMatch>
Can anybody tell me what this does?
RewriteRule .* .main.php [QSA,L]
From what I understand it will rewrite ANYTHING to main.php correct? But not so sure what the QSA,L does.
This is the whole .htaccess file, when I hit the main directory I get a 400 Bad Request error. Edit: Bad request went away when I added an ending slash in the browser to the root directory of this script.
RewriteEngine On
# Transfering to the main tranfer file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !\.css$
RewriteCond %{REQUEST_FILENAME} !\.js$
RewriteRule .* .main.php [QSA,L]
# nobody is allowed to access the access the INI file
<FilesMatch "\.inc.php$">
Order allow,deny
Deny from all
</FilesMatch>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QSA = 查询字符串附加:将现有查询字符串附加到重写的规则中
L = 最后一条规则:集合的最后一条规则,不处理任何后续
RewriteRule
查看 文档 了解更多信息。
您是否有名为
.main.php
的文件?点前缀让我担心。您的规则显示,除非请求是存在的符号链接,或者具有 CSS 或 JS 扩展,否则它将转到.main.php
QSA = Query String Append: append the existing query string to the re-written rule
L = Last Rule: last rule of the set, don't process any following
RewriteRule
Check out the documentation for more.
Do you have a file that is named
.main.php
? The dot prefix worries me. Your rules read that unless the request is an exists, symbolic link, or it has a CSS or JS extension it goes to.main.php