Loading...

利用 .htaccess 限制可瀏覽ip來源

Temperature: 0 °C

Mark ChangMark Chang
author_tools

要如何限制某個資料夾內容只能給特定IP讀取?

這個部分其實可以透過.htaccess快速實現~

首先你當然得要有.htaccess得檔案

並在內容裡加入以下設定:


RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^0.0.0.0 #限制只能哪個IP可以讀取
RewriteCond %{REMOTE_ADDR} !^0.0.0.1 #可限制多組IP以此類推
RewriteRule .* https://URL/ [R,L] #想要轉只到哪個網站?

上述方式是以多筆固定IP為例。

當然若你想要設定的是否個網段,你也可以將固定IP更改如下

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^0.0.0.* #限制只能哪個IP可以讀取
RewriteRule .* https://URL/ [R,L] #想要轉只到哪個網站?

客戶需要,所以也特別記錄下來~

https://innstory.com/story-利用_htaccess_限制可瀏覽ip來源-1864
Linux

Prev
 Android_禁止螢幕旋轉

Next
Android_Fragment及Activity_中使用sharedpreferences 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

Fatal error: Allowed memory size of 50331648 bytes exhausted (tried to allocate 12288 bytes) in

Fatal error: A...

今天在客戶的網站系統上發現了一個問題。 在上傳檔案時發生了一個錯誤: Fatal error: Al...

解決svchost.exe消耗記憶體問題

解決svchost.exe消...

pexelsphotowin55 根據微軟中文知識庫編號5的文件說明:「SVCHOST.EXE是從動...

點選檔案下載卻直接執行開啟

點選檔案下載卻直接執行開啟

遇到一個情況。 使用者開啟瀏覽器點選某個連結檔案時,不會執行下載而是直接開啟檔案。 原本如果只是圖片...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format