简体   繁体   English

如何在特定文件夹中不应用特定的 htaccess 规则?

[英]How to have specific htaccess rules not to be applied in a specific folder?

I have the following htaccess into my root directory.我的根目录中有以下 htaccess。 However I want it to be applied anywhere EXCEPT the admin dir.但是我希望它可以应用于除admin目录之外的任何地方。

How can I achieve this?我怎样才能做到这一点?

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

<IfModule mod_headers.c>
# Set XSS Protection header
Header set X-XSS-Protection "1; mode=block"
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>

You can override those settings by putting a separate .htaccess file in the admin directory, setting ExpiresByType text/html "access plus 1 hours" for example.您可以通过在admin目录中放置一个单独的 .htaccess 文件来覆盖这些设置,例如设置ExpiresByType text/html "access plus 1 hours" Or if you have full access to the Apache config files you could use the <Directory> directive.或者,如果您拥有对 Apache 配置文件的完全访问权限,则可以使用<Directory>指令。 (see: https://httpd.apache.org/docs/2.4/mod/core.html#directory ) (见: https : //httpd.apache.org/docs/2.4/mod/core.html#directory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM