Linux 系统下.htaccess 经典使用范例


Derek 2007年11月03日 05时14分 , 星期六

  1. 页面和URL跳转
  2.   页面跳转:Redirect /OldDir/old.html http://site.com/NewDir/new.html
      URL跳转:Redirect /link http://www.MerchantDomain.com/affil.cgi?12345
           将http://YourSite.com/link 指向 http://www.MerchantDomain.com/affil.cgi?12345

  3. 404 (Not Found) 和 500 (Internal Server Error)出错页面定制
  4.      ErrorDocument 404 /404.html
         ErrorDocument 500 /500.html

  5. 保护服务器端文件目录
  6.   IndexIgnore *
      IndexIgnore *.gif *.jpg

  7. 将 YourSite.com 与 www.YourSite.com匹配
  8.   有时网络搜索引擎将二者分开处理成两个单独的网站,因而会招致所谓“网站抄袭”的处罚(Google就是这么武断霸道,不就是有几个臭钱!)。解决方法是:
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^YourSite\.com [nc]
      RewriteRule (.*) http://www.YourSite.com/$1 [R=301,L]

发表新评论

此内容将保密,不会被其他人看见。
  • 网页地址和电子邮件地址将会被自动转换为链接。
  • Allowed HTML tags: <a> <em> <strong> <small> <sup> <sub> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <br> <br /> <p> <div> <span> <b> <i>
  • 行和段被自动切分。
  • You may use [img:xx] tags to display uploaded files or images inline.

更多格式化选项信息

请输入您在上图中看到的字符(字母区分大小写)