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>
    #文件缓存时间配置
  • 相关阅读:
    shell eval命令
    嘟嘟嘟
    07 linkextractor的基本用法
    rabbitmq消息队列
    5. 哨兵集群
    4.主从同步
    3. redis持久化存储
    2. redis 安全
    1.redis基础
    06. scrapy的Request对象
  • 原文地址:https://www.cnblogs.com/sustudy/p/5213188.html
Copyright © 2011-2022 走看看