HTACCESS 重写顺序
重写index.php的行和其他三行工作得很好,但放在一起时就不行了,我已经尝试了行位置的所有可能性,说实话,我已经筋疲力尽了。
我的代码如下:
RewriteEngine On
RewriteRule (.*) index.php
RewriteCond %{REQUEST_URI} !^/(admin|admin/.*)$
RewriteCond %{REQUEST_URI} !^/(l|l/.*)$
RewriteCond %{REQUEST_URI} !^/(includes|includes/.*)$
任何人都可以帮我解决这个简单的问题吗?
该脚本运行于: http://domain.com/folder/
.htaccess 也放置在该文件夹中。
问题是它还重写了 admin,l 中的文件并包含文件夹
The line with rewriting index.php and the other three lines work perfectly, but not when put together, I've tried all possibilities with position of the lines, and to be honest pretty exhausted.
My code below:
RewriteEngine On
RewriteRule (.*) index.php
RewriteCond %{REQUEST_URI} !^/(admin|admin/.*)$
RewriteCond %{REQUEST_URI} !^/(l|l/.*)$
RewriteCond %{REQUEST_URI} !^/(includes|includes/.*)$
Can anyone help me in this quick question?
The script runs in: http://domain.com/folder/
The .htaccess is also placed in that folder.
The problem is that it rewrites also files in the admin,l and includes folder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这里发生的事情是第一个 RewriteRule (.*) index.php 设置为重写所有内容,无论它们是否与 3 RewriteCond 的其他正则表达式匹配,我认为可能会将其移至底部并重新制定规则以使其更具体满足您的需求。
I think what is happening here is the first RewriteRule (.*) index.php is set to rewrite everything regardless of if they match the other regex for the 3 RewriteCond's I think maybe moving it to the bottom and reformulating the rule to be more specific to your needs.
您的 Rewrite 代码中存在很少的问题:
将您的代码替换为:
There are few problems in your Rewrite code:
Replace your code with this: