Linux 系统下.htaccess 经典使用范例
- 页面和URL跳转
- 404 (Not Found) 和 500 (Internal Server Error)出错页面定制
- 保护服务器端文件目录
- 将 YourSite.com 与 www.YourSite.com匹配
页面跳转: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
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
IndexIgnore *
IndexIgnore *.gif *.jpg
有时网络搜索引擎将二者分开处理成两个单独的网站,因而会招致所谓“网站抄袭”的处罚(Google就是这么武断霸道,不就是有几个臭钱!)。解决方法是:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^YourSite\.com [nc]
RewriteRule (.*) http://www.YourSite.com/$1 [R=301,L]
- 91 次阅读

发表新评论