htaccess 使用参数重写规则

htaccess Rewrite rules with parameters

我的服务器根目录下有以下文件:

/index.php
/css/file.css
/js/file.js

我想重定向:

到目前为止,我有以下 .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} /entry/ [NC]
    RewriteRule ^entry/(.*)$ index.php?entry= [QSA,NC,L]

</IfModule>

问题是 cssjs 文件没有正确提供。

那是因为浏览器要求文件:

我该如何解决?

谢谢

使用那个:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -s
    RewriteRule ^ - [L]

    RewriteRule ^entry/(.+\.(?:js|css))$  [NC,L]

    RewriteRule ^/content/ag(.*)$ index.php?entry= [QSA,NC,L]
    RewriteRule ^entry/(.*)$ index.php?entry= [QSA,NC,L]
</IfModule>

并添加你的 html header:

<base href="/">

我为 .js 和 .css
添加重写 但您可以添加其他格式,例如 .gif 或 .png...