.htaccess对没有物理目录的路径禁用缓存控制mod_expires和mod_headers

时间:2015-12-10 14:55:39

标签: apache .htaccess laravel cache-control

我有Laravel应用程序,它在公用文件夹中使用mod_expires,mod_headers和mod_gzip来启用站点前端的缓存。但是,在管理面板中,这打破了一些功能。

我想禁用/排除使用mod_rewrite生成的管理面板的路径。我只是将一个.htaccess文件放在一个与路径名相同的文件夹中,但这也会导致问题。

管理面板的路径是" / manage"。

这里是.htaccess文件目前的样子。

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>    

    RewriteEngine On    

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]    

    # Secure Front Themes...
    RewriteRule ^themes/.*\.(blade.php|php)$ - [F,L,NC]    

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault "access plus 1 seconds"
      ExpiresByType image/x-icon "access plus 2592000 seconds"
      ExpiresByType image/jpeg "access plus 2592000 seconds"
      ExpiresByType image/png "access plus 2592000 seconds"
      ExpiresByType image/gif "access plus 2592000 seconds"
      ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
      ExpiresByType text/css "access plus 604800 seconds"
      ExpiresByType text/javascript "access plus 216000 seconds"
      ExpiresByType application/x-javascript "access plus 216000 seconds"
      ExpiresByType text/html "access plus 600 seconds"
      ExpiresByType application/xhtml+xml "access plus 600 seconds"
    </IfModule>    

    <IfModule mod_headers.c>
        <FilesMatch "\\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "max-age=2692000, public"
        </FilesMatch>
        <FilesMatch "\\.(css)$">
        Header set Cache-Control "max-age=2692000, public"
        </FilesMatch>
        <FilesMatch "\\.(js)$">
        Header set Cache-Control "max-age=216000, private"
        </FilesMatch>
        <FilesMatch "\\.(x?html?|php)$">
        Header set Cache-Control "max-age=600, private, must-revalidate"
        </FilesMatch>

        Header unset ETag
        Header unset Last-Modified
    </IfModule>    

    <ifModule mod_gzip.c>
        mod_gzip_on Yes
        mod_gzip_dechunk Yes
        mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
        mod_gzip_item_include handler ^cgi-script$
        mod_gzip_item_include mime ^text/.*
        mod_gzip_item_include mime ^application/x-javascript.*
        mod_gzip_item_exclude mime ^image/.*
        mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>

提前致谢

0 个答案:

没有答案