iis/nginx/apache配置301http跳转到https

记录下常用的http跳转https的301配置,免得以后到处找

iis配置方式:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
     </conditions>
     <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
   </rules>
  </rewrite>
 </system.webServer>
</configuration>

nginx配置方式:

rewrite ^(.*)$  https://$host$1 permanent;
#最新版新增方法
return    301 https://$server_name$request_uri;
#两种方法取一中

apache配置方式:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/561.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。