常规web服务器HTTPS跳转设置
于
2023-10-12
发表
复制链接
打印
555人查看
Apache:
网站的<Directory>标签下添加以下语句
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R=301]
Nginx:
HTTP配置中添加以下语句
rewrite ^(.*)$ https://$host$1 permanent;
Tomcat:
将server.xml中HTTP配置的redirectPort端口修改为443
<Connector port=”80″ protocol=”HTTP/1.1″ connectionTimeout=”20000″ redirectPort=”443″ />
在web.xml文件内容<web-app>……</web-app>中增加以下配置
<security-constraint>
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
IIS:
HTTP重定向:IIS跳转-HTTP重定向
URL重写:IIS跳转-URL重写