Apache 单独的管理和根重写规则(mod_rewrite)

Apache 单独的管理和根重写规则(mod_rewrite),apache,mod-rewrite,Apache,Mod Rewrite,这是我当前的htaccess,我使用mod_rewrite RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !^/?admin/.+$ index.php [L] RewriteRule ^admin/(.*)$ admin/index.php [L] 我需要将管理请求重写为admin/index.php,并将其他请求重写为/index.php 示

这是我当前的htaccess,我使用mod_rewrite

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^/?admin/.+$ index.php [L]
RewriteRule ^admin/(.*)$ admin/index.php [L]
我需要将管理请求重写为
admin/index.php

,并将其他请求重写为
/index.php

示例:
localhost/example
/index.php

localhost/foo/bar
/index.php

localhost/admin/login/
admin/index.php

localhost/admin/pages/
admin/index.php


上述规则运行良好,但也适用于css样式或Java脚本。这意味着
admin/js/jquery.js
也将重写为
admin/index.php
(文件路径存在)。我缺少什么?

您需要复制这两个条件,这两个条件只适用于下一个
重写规则

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^/?admin/.+$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin/(.*)$ admin/index.php [L]

曾为
admin/foo
工作,但在
admin/foo/bar/…