手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

.htaccess 文件使用手册

时间:2024-10-15 02:18:20

1、设置错误页面ErrorDocument400/error_pages/400.htmlErrorDocument401/error_pages/401.htmlErrorDocument403/error_pages/403.htmlErrorDocument404/error_pages/404.htmlErrorDocument500/error_pages/500.html

2、设置重定向#从old_dir目录重定向到new_dir目录Redirect/old_dir/http://www.yourdomain.com/new_dir/index.html#把通过二级目录访问的请求301重定向到二级域名RedirectMatch301/dir/(.*)http://dir.yourdomain.com/$1

3、禁止指定IP访问#禁止IP为255.0.0.0和123.45.6.区段的IP访问orderallow,denydenyfrom255.0.0.0denyfrom123.45.6.allowfromall

4、禁止依宏氽墓指定来源访问#禁止从otherdomain.com和anotherdomain.com的来源访问Rewrit髫潋啜缅eEngineon#Options+FollowSymlinksRewriteCond%{HTTP_REFERER}otherdomain\.com[NC,OR]RewriteCond%{HTTP_REFERER}anotherdomain\.comRewriteRule.*-[F]

5、文件防盗链#从本站以外的域名访问图片,一律显示feed.jpgRewriteEngineonRewriteC泠贾高框ond%{HTTP_REFERER}!^$RewriteCond%{HTTP_REFERER}!^http://(www\.)?yourdomain.com/.*$[NC]RewriteRule\.(gif|jpg|png)$http://www.yourdomain.com/feed.jpg[R,L]

6、禁用文件夹列表#如果你的文件夹没有首页文件,服务器会显示文件列表,你可以设置不显示IndexIgnore*#仅不显示.zip/.jpg/.gif格式的文件IndexIgnore*.zip*.jpg*.gif

7、设置文件夹首页#防止显示文件夹列表,当访问文件夹时,服务器查找index.html为首页文件,如不存在依次向后查找DirectoryIndexindex.htmlindex.cgiindex.php

8、设置媒体文件为可下载的而非播放AddTypeapplication/octet-stream.mp3.mp4

9、自定义 HTTP 报头HeadersetX-Pingback"http://www.xxx.cn/xmlrpc.php"Headersetarticle-by"xxx.cn"

10、设置文件过期时间 Cache 觊皱筠桡Control<IfModulemod_expires.c>#启用有效期控制ExpiresActiveOn#gif/png/jpg有效期为1个月ExpiresByTypeimage/gif"accessplus1month"ExpiresByTypeimage/png"accessplus1month"ExpiresByTypeimage/jpg"accessplus1month"#js/css有效期为1星期ExpiresByTypetext/javascript"accessplus1week"ExpiresByTypetext/css"accessplus1week"</IfModule>

11、基本配置方法都在上面了 各位有不懂的欢迎提问~

© 手抄报圈