zoukankan      html  css  js  c++  java
  • .htaccess 配置

    1. 常规wordpress配置
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
      
      # protect xmlrpc
      <Files xmlrpc.php>
          Order Deny,Allow
          Deny from all
      </Files>
      wordpress Code
    2. 使用.htaccess做多语言版本的web
      如 EN / CH
      给"EN"添加PHP链接,点击之后生成Cookie做相应跳转,代码如下
      <?php
        setcookie("C_language","en",time()+31536000,"/"); 
        header("Location: http://www.website.com");
      ?>
      en.php Code

      .htaccess内容如下

      #### Rewrite Browser Germany Language
      RewriteCond %{HTTP_COOKIE} !.*C_language.*     //不存在cookie
      RewriteCond %{HTTP:Accept-Language} ^de [NC]   //浏览器为DE语
      RewriteRule ^$ http://www.website.com/de [R=302,L]   
      
      RewriteCond %{HTTP_COOKIE} ^C_language=de [NC]    //cookie 为de语
      RewriteRule ^$ http://www.website.com/de [R=302,L]
      .htaccess Code

      代码解释:
      初次进入网站,不存在C_language,浏览器为DE语,会打开www.website.com/de/页面
      初次进入网站,不存在C_language,浏览器为EN语,会打开www.website.com
      若用户点击了EN / CN 切换按钮,会生成C_language的Cookie,若Cookie为DE,进入www.website.com/de/页面。反之进入www.website.com
      之后的用户访问均会根据Cookie做相对应的跳转

    3. 下载文件的改写

      A、自身服务器做转换
      RewriteCond %{REQUEST_URI} Download_File_For_.*.exe$
      RewriteRule Download_File_For_.*.exe$ File_Setup.exe

      B、跳转到CDN下载服务器做转换
      RewriteCond %{REQUEST_URI} Download_File_For_.*.exe$
      RewriteRule ^(.*) http://cdn.website.com/$1 [L,R=permanent]
      下载服务器:
      RewriteEngine on
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule Download_File_For_.*.exe$ File_Setup.exe

      代码解释
      所有用户下载Download_File_For_***.exe的文件,文件名会是Download_File_For_***.exe,真实的文件确是File_Setup.exe

    4. 保护当前目录,只允许某个IP访问,如保护phpMyAdmin
      order allow,deny
      allow from 10.10.0.1
  • 相关阅读:
    HTML 5 音频
    HTML 5 视频
    HTMl链接- target/ name
    HTML 链接
    OGNL_一点
    struts_表单得到数据
    MySql_十六进制值
    HTML 事件属性(下)
    作业3-2 输入一个正整数 n,再输入 n 个学生的成绩,计算平均成绩,并统计所有及格学生的人数
    作业3-1 .输入一个整数 x,计算并输出下列分段函数 sign(x) 的值
  • 原文地址:https://www.cnblogs.com/Mrhuangrui/p/4565416.html
Copyright © 2011-2022 走看看