Apache rewrite URL but don't rewrite certain f

2019-05-22 15:08发布

问题:

I am using Apache to rewrite my URLs into clean URLs.

RewriteRule ^(.*) index.php

Currently this rewrites directories too, which is what I want, since I want everything run through my router/index.php file.

What I would like to do however, is have one folder that I can access directly. This is for lib files such as .js and .css files. I know how to do this with an Alias, but I can't use that in a .htaccess file, which I need to use.

How can I not rewrite a specific folder, eg. called "lib"?

EDIT:

I did find the following example of how to fake an Alias in .htaccess, but I can't get it working:

RewriteRule /old-folder /new-folder [PT]

回答1:

RewriteRule ^/?lib/.+$ - [L]
RewriteRule ^(.*) index.php