人人爽人人爽人人片av-无翼乌工口肉肉无遮挡无码18-国产精品久久久久久无毒不卡-日本免费一区二区三区在线播放-gogogo高清在线观看免费

Apache偽靜態規則文件.htaccess的另類用法
  • 更新時間:2024-10-24 02:34:55
  • 建站經驗
  • 發布時間:2年前
  • 333

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]

我們專注高端建站,小程序開發、軟件系統定制開發、BUG修復、物聯網開發、各類API接口對接開發等。十余年開發經驗,每一個項目承諾做到滿意為止,多一次對比,一定讓您多一份收獲!

本文章出于推來客官網,轉載請表明原文地址:https://www.tlkjt.com/experience/7593.html
推薦文章

在線客服

掃碼聯系客服

3985758

回到頂部