假設我有一個形式,現在正在做一個帖子:如何POST到HTTPs?
<form id="post-form" class="post-form"
action="https://stackoverflow.com/questions/ask/submit" method="post">
你會發現沒有網站在action
,瀏覽器遵循它從得到的頁面。
瀏覽器發佈
If the current page is... then the browser will POST to
======================================= =============
http://stackoverflow.com/questions/ask http://stackoverflow.com/questions/ask/submit
https://stackoverflow.com/questions/ask https://stackoverflow.com/questions/ask/submit
時遵循當前域規則,但我要確保瀏覽器會經常去安全頁:
http://stackoverflow.com/questions/ask https://stackoverflow.com/questions/ask/submit
通常你會嘗試類似:
<form id="post-form" class="post-form"
action="https://stackoverflow.com/questions/ask/submit" method="post">
除t帽子需要知道託管站點的域和虛擬路徑名(例如, stackoverflow.com
)。如果網站發生了變化:
stackoverflow.net
stackoverflow.com/mobile
de.stackoverflow.com
stackoverflow.co.uk/fr
beta.stackoverflow.com
然後形式action
將不得不還更新:
<form id="post-form" class="post-form" action="https://stackoverflow.net/questions/ask/submit" method="post">
<form id="post-form" class="post-form" action="https://stackoverflow.com/mobile/questions/ask/submit" method="post">
<form id="post-form" class="post-form" action="https://de.stackoverflow.com/questions/ask/submit" method="post">
<form id="post-form" class="post-form" action="https://stackoverflow.co.uk/fr/questions/ask/submit" method="post">
<form id="post-form" class="post-form" action="https://beta.stackoverflow.com/questions/ask/submit" method="post">
如何指導瀏覽器去https
版本的頁面?
假設語法:
<form id="post-form" class="post-form" action="https://./questions/ask/submit" method="post">
有你試過這個:http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite? – j08691
@ j08691我*發生*在ASP.net;但我希望獲得獨立於服務器(即客戶端)的解決方案。 –
在Apache中,我猜測可能有一種方法可以在當前目錄中用.htaccess文件做到這一點。或者肯定這可以用PHP或ASP或其他服務器語言構建。 –