0

这是我当前的 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/exampleto /index.php
localhost/foo/barto /index.php
localhost/admin/login/to to admin/index.php
localhost/admin/pages/toadmin/index.php

上述规则工作正常,但它也适用于 css 样式或 javascripts。这意味着admin/js/jquery.js也将重写admin/index.php(文件路径存在)。我错过了什么?

4

1 回答 1

2

您需要复制仅适用于下一个条件的 2 个条件RewriteRule

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]
于 2012-08-02T06:53:33.207 回答