1、开启/关闭拼写检查(关闭后会区分大小写) CheckSpelling On #开启 CheckSpelling Off #关闭 关闭拼写检查可以解决一下报错 2、禁止/只允许特定IP访问 (1) 禁止单个IP访问,例如192.168.1.1 Order Allow,Deny Allow from all Deny from 192.168.1.1 (2) 禁止IP段访问,例如192.168.1.0/24、192.168.0.0/16 Order Allow,Deny Allow from all Deny from 192.168.1 Deny from 192.168 (3) 只允许特定IP访问,例如192.168.1.1 Order Allow,Deny Deny from all Allow from 192.168.1.1 3、防止目录浏览 Options All -Indexes 4、自定义错误页面 ErrorDocument 403 /403.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html 5、设置默认首页 DirectoryIndex 123.html 6、屏蔽恶意蜘蛛(User Agent) SetEnvIfNoCase User-Agent "^Baidu" bad_bot SetEnvIfNoCase User-Agent "^sogou" bad_bot SetEnvIfNoCase User-Agent "^Bloghoo" bad_bot SetEnvIfNoCase User-Agent "^Scooter" bad_bot Deny from env=bad_bot 7、防盗链 RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ [NC] RewriteCond %{HTTP_REFERER} !google.com [NC] #白名单域名,谷歌 RewriteCond %{HTTP_REFERER} !baidu.com [NC] #白名单域名,百度 RewriteCond %{HTTP_REFERER} !test.com [NC] #白名单域名,自己的域名添加上 RewriteRule .*\.(jpg|gif|png|jpeg)$ http://deny.com [R,NC,L] #不在白名单的访问跳转到特定url上 8、禁止访问特定目录,例如拒绝任何人访问abc目录 在abc目录下创建.htaccess,写入一下内容: deny from all 9、http跳转到https RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.* https://%{SERVER_NAME}%{REQUEST_URI} [L,R] |