首页 > 网络应用 > 301跳转到https域名的方法(Apache和Kangle适用)

2317

浏览

0

评论

301跳转到https域名的方法(Apache和Kangle适用)

作者:stephen | 分类:网络应用 | 标签:

我以Apache(kangle也兼容)web服务器为例,展示下本博客(wordpress程序)的.htaccess文件代码:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.johntitorblog.com/$1 [R=301,L]

而下面的代码应该是比较通用的,适合非wordpress程序:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.xxx.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^xxx.com [NC]
RewriteRule ^(.*)$ https://www.xxx.com/$1 [L,R=301]

该代码设置后所有的域名都会跳转到https带www的域名下,状态码是301,全站链接都会跳,是完美的。


本文链接:https://www.stephenwxf.com/post/120.html
原创文章如转载请注明:转载自王显璠的个人博客谢谢!

Copyright Your stephenwxf.com Rights Reserved.