.htaccess的帮助下,$ 1的集之前使用???什么?htaccess

2023-09-02 20:37:39 作者:高姿态、男子

我有这样的片段

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

It won't allow me to access a file at website.com/js/main.php but it will let me access index.php

据我的虚拟主机提供商,$ 1被调用它设置之前。任何解决办法?

According to my webhost, $1 is being called before it is set. Any solutions?

我会接受的答案,当我回来的明天。谢谢!

I'll accept answers when i get back tomorrow. Thank you!

推荐答案

我假设你要重写忽略的事情,你的病情目前指定。在这种情况下...

I'm assuming you want the rewrite to ignore the things which your condition currently specifies. In that case...

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。

...should work fine. You'll probably want the QSA on there so that if there's a query string, it's properly handled.