Regex 如何将所有url请求重定向到index.php/path/variables,以img/开头的请求除外?
我有一些简单的重写规则,可以将所有路径变量重定向到/index.php。但现在我想为所有/img/(*)URL做一个例外 这里有一个片段。请告知Regex 如何将所有url请求重定向到index.php/path/variables,以img/开头的请求除外?,regex,mod-rewrite,rewrite,apache,Regex,Mod Rewrite,Rewrite,Apache,我有一些简单的重写规则,可以将所有路径变量重定向到/index.php。但现在我想为所有/img/(*)URL做一个例外 这里有一个片段。请告知 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rewr
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]
我尝试将重写规则^img/(*)img/index.php/$1[L]
添加到最后一行catchall的上方,但它不起作用
我想要的结果是这样的:
url --> script / path variables
====================================
/abc/def --> /index.php/abc/def
/img/abc --> /img/index.php/abc
你能给我指出正确的方向吗?你不仅需要将其添加到最后一条catchall线的上方,还需要保留catchall所需的条件,并同样为你自己的
/img/
路由复制这些条件:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^img/(.*) img/index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]