.htaccess 是否未考虑重写规则最后[L]标志?

.htaccess 是否未考虑重写规则最后[L]标志?,.htaccess,url-rewriting,.htaccess,Url Rewriting,我创建了一个在IIS服务器上运行良好的php框架,重写规则在web.config上运行良好 但是同样的规则在带有.htaccess的apache服务器上不起作用,我不明白为什么。。。这是: Options +FollowSymlinks RewriteEngine On RewriteRule picture/([a-zA-Z0-9]+)/([a-zA-Z\-0-9/]+).(jpg|png|gif) app/Src/$1Bundle/public/img/$2.$3 [L] Rewr

我创建了一个在IIS服务器上运行良好的php框架,重写规则在web.config上运行良好

但是同样的规则在带有.htaccess的apache服务器上不起作用,我不明白为什么。。。这是:

Options +FollowSymlinks

RewriteEngine On

RewriteRule picture/([a-zA-Z0-9]+)/([a-zA-Z\-0-9/]+).(jpg|png|gif)    app/Src/$1Bundle/public/img/$2.$3 [L]
RewriteRule picture/([a-zA-Z\-0-9/]+).(jpg|png|gif)    public/$1.$2 [L]
RewriteRule scripts/([a-zA-Z0-9]+)/(js|css|typo)/([a-zA-Z\-0-9=\./]+).(js|css) app/Src/$1Bundle/public/$2/$3.$4 [L]
RewriteRule scripts/(js|css|typo)/([a-zA-Z\-0-9=\./]+).(js|css) public/$1/$2.$3 [L]
RewriteRule scripts/(fonts)/([a-zA-Z\-0-9=\./]+).(eot|svg|ttf|woff)   public/$1/$2.$3 [L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
我已经尝试过这个解决方案(和许多其他的解决方案),但没有成功

RewriteCond %{ENV:REDIRECT_STATUS} != 200
我已经没有主意了

您的上一条规则(重写所有内容)无条件运行,因此这将导致重写循环(500错误响应)

至少您需要防止对
index.php
的请求被进一步重写。例如:

RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
但您可能也希望静态资源保持直接可访问性?因此,排除映射到物理文件和目录的请求是一个常见的要求。例如:

RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

您还从
重写规则
模式中省略了字符串锚定的任何开头(
^
)和字符串锚定的结尾(
$
)。这可能会导致匹配过多(甚至匹配重写的URL)另一个循环。您需要在模式匹配中更加具体。

哪些URL不起作用,错误是什么?
L
标志的常见问题是人们不理解它只会终止此重写过程。但是,如果URL已被重写,则该过程将立即重新启动。如果要最终终止重写过程,请使用
END
标志。