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>
    #文件缓存时间配置
  • 相关阅读:
    python爬取糗事百科段子
    python爬虫-韩寒新浪博客博文
    python-函数
    Python-列表
    Linux学习笔记001——win下安装Linux虚拟机
    python爬虫-正则表达式
    IIS使用十大原则,(IIS过期时间,IIS缓存设置) 【转载】
    在mysql 中两种锁定问题
    php 迭代器与和生成器
    DBCP连接池使用问题
  • 原文地址:https://www.cnblogs.com/sustudy/p/5213188.html
Copyright © 2011-2022 走看看