zoukankan      html  css  js  c++  java
  • apache的 .htaccess文件的常用配置

    使用.htaccess文件需要注意的地方:

      1、找到配置文件httpd.conf,将override的值改成all。如下图:(如果不设置成all,apache将忽略.htaccess文件)

        

      2、找到配置文件httpd.conf,加载指定的模块,如下图:(一般都是加载了指定模块,然后在配置.htaccess文件才有效)

        

     以下是常用的.htaccess配置:

    #去掉网址的index.php字符串
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REGUEST_FILENAME} !-f
    RewriteCond %{REGUEST_FILENAME} !-d
    #设置public字符串不跳转是要访问资源文件
    RewriteRule !^(index.php|public)  aaa/index.php [L] 
    #去掉网址的index.php字符串
    
    #GZIP压缩模块配置
    <ifmodule mod_deflate.c>
        #启用对特定MIME类型内容的压缩
        SetOutputFilter DEFLATE
        #设置不要压缩的文件
        SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|t?gz|zip|bz2|sit|rar|pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary
        #设置要压缩的文件
        AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-httpd-php application/x-javascript 
    </ifmodule>
    #GZIP压缩模块配置
    
    #文件缓存时间配置
    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css)$">
        Header set Cache-Control "max-age=0" 
    </FilesMatch>
    #文件缓存时间配置
  • 相关阅读:
    hdu1874 畅通工程续
    hdu2544 最短路
    hdu1068 Girls and Boys
    hdu1151 Air Raid
    hdu1150 Machine Schedule
    hdu2063 过山车
    Bootstrap 学习笔记12 轮播插件
    Bootstrap 学习笔记11 按钮和折叠插件
    Bootstrap 学习笔记10 弹出框和警告框插件
    Bootstrap 学习笔记9 标签页和工具提示插件
  • 原文地址:https://www.cnblogs.com/sustudy/p/5213188.html
Copyright © 2011-2022 走看看