设置错误页面- ErrorDocument 400 /error_pages/400.html
- ErrorDocument 401 /error_pages/401.html
- ErrorDocument 403 /error_pages/403.html
- ErrorDocument 404 /error_pages/404.html
- ErrorDocument 500 /error_pages/500.html
复制代码
设置重定向
- #从 old_dir 目录重定向到 new_dir 目录
- Redirect /old_dir/ http://www.kaikuoyun.com/new_dir/index.html
- #把通过二级目录访问的请求 301 重定向到二级域名
- RedirectMatch 301 /dir/(.*) http://dir.kaikuoyun.com/$1
复制代码
禁止指定 IP 访问- #禁止 IP 为 255.0.0.0 和 123.45.6.区段的 IP 访问
- order allow,deny
- deny from 255.0.0.0
- deny from 123.45.6.
- allow from all
复制代码
禁止指定来源访问
- #禁止从 kaikuoyun.com 和 www.kaikuoyun.com 的来源访问
- RewriteEngine on
- # Options +FollowSymlinks
- RewriteCond %{HTTP_REFERER} kaikuoyun\.com [NC,OR]
- RewriteCond %{HTTP_REFERER} www.kaikuoyun\.com
- RewriteRule .* - [F]
复制代码
文件防盗链
- #从本站以外的域名访问图片,一律显示 feed.jpg
- RewriteEngine on
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://(www\.)?kaikuoyun.com/.*$ [NC]
- RewriteRule \.(gif|jpg|png)$ http://www.kaikuoyun.com/feed.jpg [R,L]
复制代码
禁用文件夹列表
- #如果你的文件夹没有首页文件,服务器会显示文件列表,你可以设置不显示
- IndexIgnore *
- #仅不显示 .zip/.jpg/.gif 格式的文件
- IndexIgnore *.zip *.jpg *.gif
复制代码
设置文件夹首页
- #防止显示文件夹列表,当访问文件夹时,服务器查找 index.html 为首页文件,如不存在依次向后查找
- DirectoryIndex index.html index.cgi index.php
复制代码
设置媒体文件为可下载的而非播放
- AddType application/octet-stream .mp3 .mp4
复制代码
自定义 HTTP 报头
- Header set X-Pingback "http://www.kaikuoyun.com/xmlrpc.php"
- Header set article-by "kaikuoyun.com"
复制代码
设置文件过期时间 Cache Control
- # 启用有效期控制
- ExpiresActive On
- # gif/png/jpg 有效期为 1 个月
- ExpiresByType image/gif "access plus 1 month"
- ExpiresByType image/png "access plus 1 month"
- ExpiresByType image/jpg "access plus 1 month"
- # js/css 有效期为 1 星期
- ExpiresByType text/javascript "access plus 1 week"
- ExpiresByType text/css "access plus 1 week"
复制代码
判断User-agent 阻止迅雷下载
- ExpiresActive On
- RewriteCond %{HTTP_USER_AGENT} 2.0.50727 [NC]
- RewriteRule . 123.txt [L]
复制代码
|