{"id":252,"date":"2021-08-04T12:03:16","date_gmt":"2021-08-04T04:03:16","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=252"},"modified":"2021-08-04T12:03:16","modified_gmt":"2021-08-04T04:03:16","slug":"http%e5%ae%9e%e7%8e%b0%e8%87%aa%e5%8a%a8%e8%b7%b3%e8%bd%achttps%e7%9a%84%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2021\/08\/04\/http%e5%ae%9e%e7%8e%b0%e8%87%aa%e5%8a%a8%e8%b7%b3%e8%bd%achttps%e7%9a%84%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95\/","title":{"rendered":"http\u5b9e\u73b0\u81ea\u52a8\u8df3\u8f6chttps\u7684\u8bbe\u7f6e\u65b9\u6cd5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Apache \u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u9700\u8981\u6574\u7ad9\u8df3\u8f6c\uff0c\u5219\u5728\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6\u7684&lt;Directory&gt;\u6807\u7b7e\u5185\uff0c\u952e\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteEngine on<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteCond %{SERVER_PORT} !^443$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteRule ^(.*)?$ https:\/\/%{SERVER_NAME}\/$1 [L,R=301]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u5bf9\u67d0\u4e2a\u76ee\u5f55\u505ahttps\u5f3a\u5236\u8df3\u8f6c\uff0c\u5219\u590d\u5236\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteEngine on<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteBase \/yourfolder<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteCond %{SERVER_PORT} !^443$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">#RewriteRule ^(.*)?$ https:\/\/%{SERVER_NAME}\/$1 [L,R]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">RewriteRule ^.*$ https:\/\/%{SERVER_NAME}%{REQUEST_URI} [L,R=301]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u53ea\u9700\u8981\u5bf9\u67d0\u4e2a\u7f51\u9875\u8fdb\u884chttps\u8df3\u8f6c\uff0c\u53ef\u4ee5\u4f7f\u7528redirect 301\u6765\u505a\u8df3\u8f6c\uff01redirect 301&nbsp; \/\u4f60\u7684\u7f51\u9875 https:\/\/\u4f60\u7684\u4e3b\u673a+\u7f51\u9875<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx\u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u914d\u7f6e80\u7aef\u53e3\u7684\u6587\u4ef6\u91cc\u9762\uff0c\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">server {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; listen&nbsp; &nbsp; &nbsp; &nbsp;80;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; server_name&nbsp; localhost;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<strong>rewrite<\/strong>&nbsp;^(.*)$ https:\/\/$host$1 permanent;&nbsp; &nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">IIS \u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">IIs\u4e2d\u5b9e\u73b0Http\u81ea\u52a8\u8f6c\u6362\u5230Https\u65b9\u6cd5\u4ecb\u7ecd (403\u8df3\u8f6c\u5bf9SEO\u6709\u4e00\u5b9a\u5f71\u54cd)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u6839\u636eIIS\u7248\u672c\u5907\u4efd\u4ee5\u4e0b\u6587\u4ef6\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">IIS6.0 \u8def\u5f84\uff1aC:\\WINDOWS\\Help\\iisHelp\\common\\403-4.htm&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">IIS7.0\u4ee5\u4e0a \u8def\u5f84\uff1aC:\\inetpub\\custerr\\zh-CN\\403.htm<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u628a\u4ee5\u4e0b\u5185\u5bb9\u5168\u90e8\u62f7\u8d1d\u66ff\u6362\uff08403-4\u6216403\uff09\u91cc\u9762\u6240\u6709\u5185\u5bb9\uff0c\u4fdd\u5b58\u5373\u53ef<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;\u8be5\u9875\u5fc5\u987b\u901a\u8fc7\u5b89\u5168\u901a\u9053\u67e5\u770b&lt;\/TITLE&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;META HTTP-EQUIV=&#8221;Content-Type&#8221; Content=&#8221;text\/html; charset=GB2312&#8243;&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/HEAD&gt;&lt;BODY&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;script type=&#8221;text\/javascript&#8221;&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">var url = window.location.href;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (url.indexOf(&#8220;https&#8221;) &lt; 0) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url = url.replace(&#8220;http:&#8221;, &#8220;https:&#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.location.replace(url);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/script&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/BODY&gt;&lt;\/HTML&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u91ca\uff1aIIS6\u4e2d\uff0c\u7ad9\u70b9\u5c5e\u6027-\u300b\u76ee\u5f55\u5b89\u5168\u6027-\u300b\u7f16\u8f91\u4e2d\u628a\u201c\u8981\u6c42\u5b89\u5168\u901a\u9053\uff08SSL\uff09\u201d\u52fe\u9009\u4e0a\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IIS7\u30018\u4e2d\uff0cSSL\u8bbe\u7f6e-\u300b\u628a\u201c\u8981\u6c42SSL\u201d\u52fe\u9009\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">TOMCAT \u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u5728conf\u76ee\u5f55\u4e0b\u7684server.xml\u6587\u4ef6\u4e2d\u627e\u5230\u4ee5\u4e0b\u914d\u7f6e\uff0c\u4fee\u6539redirectPort\u53c2\u6570\u503c\u4e3a&#8221;443&#8243;\uff0c\u9ed8\u8ba4\u662f\u201c8443\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;Connector port=&#8221;80&#8243; protocol=&#8221;HTTP\/1.1&#8243; connectionTimeout=&#8221;20000&#8243; redirectPort=&#8221;443&#8243; \/&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u5728conf\u76ee\u5f55\u4e0b\u7684web.xml\u6587\u4ef6\u5185\u5bb9&lt;web-app&gt;\u2026\u2026&lt;\/web-app&gt;\u4e2d\u589e\u52a0\u4ee5\u4e0b\u914d\u7f6e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;web-app&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;&#8230;&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;security-constraint&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &lt;web-resource-collection &gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp;&lt;web-resource-name &gt;SSL&lt;\/web-resource-name&gt;&nbsp; &nbsp; &nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp;&lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp;&lt;\/web-resource-collection&gt;&nbsp; &nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp;&lt;user-data-constraint&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;transport-guarantee&gt;CONFIDENTIAL&lt;\/transport-guarantee&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp;&lt;\/user-data-constraint&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/security-constraint&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/web-app&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5355\u72ec\u9875\u9762\u901a\u7528\u4ee3\u7801\u6bb5\uff1a\u4ee5\u4e0b\u65b9\u6cd5\u8f83\u9002\u5408\u6307\u5b9a\u67d0\u4e00\u4e2a\u5b50\u9875\u5355\u72echttps<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u9700\u8981\u5f3a\u5236\u4e3ahttps\u7684\u9875\u9762\u4e0a\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u5904\u7406http&#8211;&gt;https<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;script type=&#8221;text\/javascript&#8221;&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; var url = window.location.href;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; if (url.indexOf(&#8220;https&#8221;) &lt; 0) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; url = url.replace(&#8220;http:&#8221;, &#8220;https:&#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; window.location.replace(url);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/script&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u9700\u8981\u5f3a\u5236\u4e3ahttp\u7684\u9875\u9762\u4e0a\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u5904\u7406<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">https&#8211;&gt;http<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;script language=&#8221;JavaScript&#8221; type=&#8221;text\/JavaScript&#8221;&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">function redirect()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; var loc = location.href.split(&#8216;:&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; if(loc[0]==&#8217;https&#8217;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; location.href=&#8217;http:&#8217;+loc[1];&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">onload=redirect&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;\/script&gt;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PHP\u9875\u9762\u8df3\u8f6c\uff1a\u6dfb\u52a0\u5728\u7f51\u7ad9php\u9875\u9762\u5185<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if ($_SERVER[&#8220;HTTPS&#8221;] &lt;&gt; &#8220;on&#8221;)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$xredir=&#8221;https:\/\/&#8221;.$_SERVER[&#8220;SERVER_NAME&#8221;].$_SERVER[&#8220;REQUEST_URI&#8221;];&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">header(&#8220;Location: &#8220;.$xredir);&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>http\u8df3\u8f6chttps<\/strong>\u7684\u65b9\u6cd5\u8f83\u591a\uff0c\u4ee5\u4e0a\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache \u7248\u672c \u5982\u679c\u9700\u8981\u6574\u7ad9\u8df3\u8f6c\uff0c\u5219\u5728\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6\u7684&#038;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-252","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":0,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}