.htaccess Htaccess帮助$1在其设置之前使用???什么?
我有这个片段.htaccess Htaccess帮助$1在其设置之前使用???什么?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有这个片段 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt) RewriteRule (.*) index.php?/$1 [L] 它不允许我访问website.com/js/main.php上的文件 但它可以让我访问index.php 根据
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt)
RewriteRule (.*) index.php?/$1 [L]
它不允许我访问website.com/js/main.php上的文件
但它可以让我访问index.php
根据我的webhost,在设置之前会调用$1。有什么解决办法吗
我明天回来时会接受答案的。谢谢大家! 我假设您希望重写忽略您的条件当前指定的内容。那样的话
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond !^(index\.php|images|img|css|js|robots\.txt)
RewriteRule (.*) index.php?/$1 [L,QSA]
…应该很好。您可能希望QSA在那里,这样,如果有查询字符串,它就会得到正确处理。我假设您希望重写忽略您的条件当前指定的内容。那样的话
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond !^(index\.php|images|img|css|js|robots\.txt)
RewriteRule (.*) index.php?/$1 [L,QSA]
…应该很好。您可能希望QSA在那里,这样,如果有查询字符串,它就会得到正确处理。您的web主机是错误的。最重要的是:
重写规则
中的模式(这将用值填充$N
引用)RewriteCond
条件(如果存在)(.*)
在当前URL路径js/main.php
(不带本地前缀/
)上进行测试。它与($0
=js/main.php
,$1
=js/main.php
)匹配,因此三个相关条件按其出现的顺序进行测试:
RewriteCond%{REQUEST\u FILENAME}-f
RewriteCond%{REQUEST\u FILENAME}-d
RewriteCond$1^(index\.php | images | img | css | js | robots\.txt)
假设请求的URL路径
/js/main.php
未引用现有文件或目录,则第一个条件均为true。但是第三个将计算为false,因为$1
=js/main.php
和模式^(index\.php | images | img | css | js | robots\.txt)
匹配(^js
分支)js/main.php
。因此,条件未满足,规则未应用。您的web主机错误。最重要的是:
重写规则
中的模式(这将用值填充$N
引用)RewriteCond
条件(如果存在)(.*)
在当前URL路径js/main.php
(不带本地前缀/
)上进行测试。它与($0
=js/main.php
,$1
=js/main.php
)匹配,因此三个相关条件按其出现的顺序进行测试:
RewriteCond%{REQUEST\u FILENAME}-f
RewriteCond%{REQUEST\u FILENAME}-d
RewriteCond$1^(index\.php | images | img | css | js | robots\.txt)
假设请求的URL路径
/js/main.php
未引用现有文件或目录,则第一个条件均为true。但是第三个将计算为false,因为$1
=js/main.php
和模式^(index\.php | images | img | css | js | robots\.txt)
匹配(^js
分支)js/main.php
。因此,条件未满足,规则未应用。似乎不起作用,它现在给我500个错误。谢谢,您可以尝试将其更改为RewriteCond%{REQUEST\u URI}^(index\.php | images | img | css | js | robots\.txt)
只是为了说明一下,它似乎不起作用,现在给了我500个错误。谢谢,您可以尝试将其更改为RewriteCond%{REQUEST\u URI}^(index\.php | images | img | css | js | robots\.txt)
只是为了说明一下,Gubmo评论中的链接非常有用,但URL现在似乎是:Gubmo评论中的链接非常有用,但URL现在似乎是: