http 与 https 所指向的站点目录不同?

2018-11-08 01:30:25 +08:00
 Mayuri

最近倒腾一个 VPS 却出现了子域名 a.aa.com 通过 HTTPS 却转到了 aa.com 站点目录 的神奇现象,这几天都在纠结这个问题

求各位大神解决我的疑惑。。。百度谷歌了一圈都无果

2758 次点击
所在节点    问与答
16 条回复
also24
2018-11-08 02:11:46 +08:00
先贴个配置出来嘛~
xmlf
2018-11-08 07:38:11 +08:00
我最近也遇到这样奇怪的事
PressOne
2018-11-08 08:24:55 +08:00
应该是证书的问题,是免费的证书吗?
Vhc
2018-11-08 08:41:31 +08:00
我这边访问 a.aa.com 并未自动跳转到 aa.com
楼主电脑中毒了吧?
Mayuri
2018-11-08 09:01:09 +08:00
@also24 aa.com 不太好看 我换成 example.com 。。
```httpd-vhost.conf ``` 配置如下
```
<VirtualHost *:80>
ServerAdmin webmaster@example.com
#php_admin_value open_basedir "/var/www/html/a:/tmp/:/var/tmp/:/proc/"
DocumentRoot "/var/www/html/a"
ServerName a.example.com
ErrorLog "/home/wwwlogs/a.example.com-error_log"
CustomLog "/home/wwwlogs/a.example.com-access_log" combined
<Directory "/var/www/html/a">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@example.com
#php_admin_value open_basedir "/home/wwwroot/example.com:/tmp/:/var/tmp/:/proc/"
DocumentRoot "/home/wwwroot/example.com"
ServerName example.com
ErrorLog "/home/wwwlogs/example.com-error_log"
CustomLog "/home/wwwlogs/example.com-access_log" combined
<Directory "/home/wwwroot/example.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>
```
Mayuri
2018-11-08 09:02:11 +08:00
@Vhc 并不是电脑中毒了。。在手机上,别的电脑上访问也是如此,各种浏览器也是如此
Mayuri
2018-11-08 09:02:37 +08:00
@PressOne 是的,Let's Encrypt 免费证书
imdong
2018-11-08 09:10:25 +08:00
http 和 https 对 nginx 来说 其实可以是两个不同的网站。
所以,检查下 nginx 和 apache 里面 https 和 http 对应的目录是否是同一个吧。
apache 不是很懂。
配置没看到 https 的配置啊,等熟悉 apache 的人来吧。
你贴的事两个网站?
Mayuri
2018-11-08 12:58:52 +08:00
@imdong 嗯,也不知道是配置哪里出现了错误,继续等待大神
不能在每个回复发外链也不能插图。。一个是主域名另一个是子域名
Mayuri
2018-11-08 19:30:02 +08:00
@imdong @also24 @xmlf @PressOne @Vhc 问题总算解决了,只要将 vhost 下的 a.example.com.conf 文件内<VirtualHost *:443>的内容复制到 httpd-vhosts.conf 里面再重启 Apache 便行了,证书也正常😄 同时也奇怪为什么之前的配置不能够起作用。。
Vhc
2018-11-08 19:32:54 +08:00
@Mayuri #10 恭喜。我只会用 nginx,看不懂 apache 的配置文件,所以之前没有能帮到你
Vhc
2018-11-08 19:38:34 +08:00
@Mayuri #10 话说,你犯这种常识性的错误是很不应该的

拿 nginx 举例说吧,你应该检查 httpd-vhosts.conf 文件里是否有这么一行代码 include /etc/apache/vhost/*.conf;
Mayuri
2018-11-08 19:57:01 +08:00
@Vhc 没事,我也很久没在网上提问过,能回复我便很高兴了
Mayuri
2018-11-08 19:59:51 +08:00
@Vhc 然而 Apache 里的 httpd.conf 里面有一句 IncludeOptional conf/vhost/*.conf。。
Mutoo
2018-11-08 20:02:42 +08:00
80 配置里的 ServerName 写成 ServerNamen 了。
Mayuri
2018-11-08 20:23:25 +08:00
@Mutoo 抱歉抱歉,那里是我改错了,原配置是 ServeName,如果是 ServeNamen 的话。。那 http 也会访问不了吧。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/505581

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX