RewriteCond触发不需要触发的RewriteRule。默认情况下,所有文件都应被禁止。
http://example.com/inc/image.png - Allowed
http://example.com/app/assets/image.png - Forbidden (Need to be allowed)
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(inc|[a-z]+/(assets|values))/
RewriteRule ^(.*)$ - [F,L]
RewriteCond %{REQUEST_URI} ^/[a-z]+/(assets|values)/
RewriteRule ^(.*)$ /projects/$1 [L]
仅允许dir / inc / ...和/ app / assets或values /...。 / app /不是静态的。请求网址example.com/app/assets / ...已重写为example.com/projects/app/assets /