請教htaccess 禁止http,只允許https
大夥好啊!
請教我的一難題,S 了 CU,也google了,還是搞不定。
使用 .htaccess ,禁止 http 訪問,只允許 https 開頭的訪問
比如說:
http://www.chinaunix.net (以 http 方式訪問的就禁止)
https://www.chinaunix.net (以 https 方式訪問的允許通過 )
請問規則該這麼寫?
謝謝!
[ 本帖最後由 Vinsion 於 2008-9-6 20:15 編輯 ]
《解決方案》
用rewirte把http寫成https就可以了~
《解決方案》
感謝 'gavinzhm' 的幫助,
我的想法是,
假如你想訪問 chinaunix.net ,你輸入的是 http 開頭的,就禁止;
假如你輸入的是 https 開頭的,就通過,而不是把 http 轉到 https
《解決方案》
關了80埠不可以嗎?
《解決方案》
原帖由 xi2008wang 於 2008-9-6 21:17 發表 http://bbs.chinaunix.net/images/common/back.gif
關了80埠不可以嗎?
關閉80埠也是一個辦法,可惜我用的是虛擬主機(買的空間)
《解決方案》
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^web_mail(.*) https://%{SERVER_NAME}/web_mail$1
《解決方案》
感謝 'ipaddr' 的幫助,但功能還是實現不了。
暫時使用 http 轉向 https 用著先.
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}
《解決方案》
原帖由 Vinsion 於 2008-9-7 22:52 發表 http://bbs.chinaunix.net/images/common/back.gif
感謝 'ipaddr' 的幫助,但功能還是實現不了。
暫時使用 http 轉向 https 用著先.
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}
需要載入mod_ssl
還要配置HTTPS,配置HTTPS的虛擬主機。
《解決方案》
<Directory /usr/local/apache/htdocs/>
SSLVerifyClient require
</Directory>
《解決方案》
原帖由 finddream 於 2008-9-8 16:07 發表 http://bbs.chinaunix.net/images/common/back.gif
SSLVerifyClient require
這個不對吧,看上去是要求客戶端有證書。