.htaccess忽略标志,不匹配下一个规则


.htaccess ignoring flags, not matching next rule

我正在构建简单的php mvc应用程序,但有问题。htaccess,它看起来像是忽略标志,不想运行下一行

Options -MultiViews
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(en|sk)('/)(.+)$ index.php?url=$3&lang=$1 [C]
RewriteRule ^(.+)$ index.php?url=$1 [C]

我的目标是有多语言网站的地址,如http://example.com/lang/something,我使用这作为mvc骨架链接到github的repo,但它行为不当

http://127.0.0.10时,一切正常当去http://127.0.0.10/en/home页也工作当转到http://127.0.0.10/home页不工作

然后当我删除第一个规则或交换规则顺序时,去http://127.0.0.10/home开始工作,但当去http://127.0.0.10/en/home不,我理解在第一种情况下错误是到位的,因为应用程序认为"en"是控制器,但在第二种情况下呢?

重写条件只适用于下一个RewriteRule,因此第二个RewriteRule没有任何条件。

试试这个代码:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^(en|sk)/(.+)$ index.php?url=$2&lang=$1 [L,QSA]
RewriteRule ^(.+)$ index.php?url=$1 [L,QSA]