我有一个使用RewriteRule的htaccess,如果你访问我的域,它将指向公共文件夹。 请参阅下面的代码
RewriteEngine on
RewriteRule ^(.*) public/$1 [L]
现在我想从通配符中排除demo目录(www.mydomain.com/demo)。 我尝试使用此代码但无法正常工作
RewriteRule ^demo($|/) - [L]
和这个
RewriteRule /demo/$1 -f
完整的htaccess代码
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/demo
RewriteRule ^(.*) public/$1 [L]
# Deflate Compression by FileType
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>
# Set browser caching to 1 month
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<ifmodule mod_headers.c>
<filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
<filesmatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesmatch>
<filesmatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesmatch>
</ifmodule>
希望有人帮助我。
由于
答案 0 :(得分:0)
RewriteCond %{REQUEST_URI} !^/demo
RewriteRule ^(.*) public/$1 [L]
RewriteCond %{REQUEST_URI} !^/demo
测试请求uri是否未以/demo
开头,然后应用下一个RewriteRule
。