赞
踩
在使用宝塔建设多个网站时,如果建两个网站A开启SSL证书,网站B未开启SSL证书当用https访问网站B的时候会强制跳转到网站A。虽然网站B没有开始https,但是搜索引擎会收录https开头的网站B,但实际收录的内容是网站A的内容,这样会造成大量A网站的重复页面,不利于优化。
官方的说明是:在未指定SSL默认站点时,未开启SSL的站点使用HTTPS会直接访问到已开启SSL的站点,但是实际情况设置了指定了默认站点,网站还是会跳转到开启ssl的网站,有种办法是网站配置监听443端口返回403,这里给大家带来另一种方法。
这里以Nginx环境为例:
实现方法就是新建一个开启SSL不能访问的网站,设置成默认站点。
第一步
创建一个站点,域名随便一个乱也一个二级域名就行,比如 sldkgda.acd.com ,域名不需要解析乱填一个就行。
第二步
删除新建站点的默认的文件
默认站点根目录有一个index.html,把它删除。
第三步开启SSL
不需要申请SSL证书,随便填写一个证书就行,这里给大家一个过期的证书,目的是未了开启SSL证书随便弄个就行。
.key文件代码:
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAlcZJiGVMbbzrWzkmhBJxjoMbFSSCtLzcY0poxwTxyxzd2pw1
45OIV9WllYNTotQyOheiJEN9hGgU/qjIRpKg/1KrSnxsykYwevMjsyM/Rs3W7MRr
EGjCqr9VfWCnC/mOhwrSeEtL76DaMTpYIYIVemK+W+BajKD5nNekjs6567phMFbm
Bsqil3hXWE31GyIaYwQqbMWI1gCSX/Tvh3dmt2dVE2/7q4soZPVSlNqEq92UENqR
6k3aQS+PoKOBj9b4Y1wtveL0bNOHqi4e7iXtucPnlWLlrpylm1ybm9Q0AUm4X0N0
k1XFB8hyOWHH0SgczbKbbHfaJEWi7kDVsUCL1wIDAQABAoIBAQCKUzJwbRX0N8mq
W5Lt4VbNRtqJYUnyAIcOkJdKT4+8hfGDyEeg4g3HCUM/XaWtuYqVymPuWAKhebsC
IwGs5BkbFc+rIFUdT0vREaND++ahztOToig7ZHV9Wu5quAwvbBEtOVp+zRPZwVYi
pv7kG48Yk/+5PPCD9tvx9ds+JUDiqrD9j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1BT
MAgGBmeBDAECATANBgkqhkiG9w0BAQsFAAOCAQEAK3Gp6/aGq7aBZsxf/oQ+TD/B
SwW3AU4ETK+GQf2kFzYZkby5SFrHdPomunx2HBzViUchGoofGgg7gHW0W3MlQAXW
M0r5LUvStcr82QDWYNPaUy4taCQmyaJ+VB+6wxHstSigOlSNF2a6vg4rgexixeiV
4YSB03Yqp2t3TeZHM9ESfkus74nQyW7pRGezj+TC44xCagCQQOzzNmzEAP2SnCrJ
sNE2DpRVMnL8J6xBRdjmOsC3N6cQuKuRXbzByVBjCqAA8t1L0I+9wXJerLPyErjy
rMKWaBFLmfK/AHNF4ZihwPGOc7w6UHczBZXH5RFzJNnww+WnKuTPI0HfnVH8lg==
-----END CERTIFICATE-----
把上边的复制到宝塔网站设置SSL
填上之后点强制开始HTTPS
第四步,把新建的站点设置成默认站点。
设置完成后,在用https访问不开SSL证书的站点就会不跳转了,直接返回403错误了。
如果网站少,可以直接把所有网站都申请SSL证书,但对于很多个网站,使用这个方法还是不错的。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。