【问题标题】:Apache redirect page to bad vhostApache 将页面重定向到错误的虚拟主机
【发布时间】:2016-07-07 05:50:04
【问题描述】:

在绑定中,我使用 CNAME 作为从 old.domain.com 到 new.domain.com 的重定向器 old.domain 也是我删除的虚拟主机 每个虚拟主机都有到 https 的 http 重定向,但问题是在 webbrowser 中输入旧地址时,即使 dig/nslookup 看到 dns cname,我也会重定向到 diff.domain.com。 当我禁用那个虚拟主机时,下一个 diff2.domain.com 会被重定向

<VirtualHost ip:80>
        ServerName diff.domain.com
        Redirect permanent / https://diff.domain.com/
</VirtualHost>

<IFModule mod_ssl.c>
        <VirtualHost ip:443>
                ServerAdmin webmaster@domain.com
                ServerName diff.domain.com:443
                DocumentRoot /var/www/diff/web
                <Directory "/var/www/diff/web">
                        Options FollowSymLinks
                        AllowOverride All
                        Order allow,deny
                        Allow from all
                        Require all granted
                </Directory>
                ErrorLog /var/www/diff/logs/error.log
                CustomLog /var/www/diff/logs/access.log combined
                SSLEngine on
                SSLCertificateFile      /etc/letsencrypt/live/diff/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/diff/privkey.pem
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

                <IfModule mod_fastcgi.c>
                        AddType application/x-httpd-fastphp5 .php
                        Action application/x-httpd-fastphp5 /php5-fcgi
 Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi_diff
                        FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi_diff -socket /var/run/php5-fpm_diff.sock -pass-header Authorization
                 </IfModule>
        </VirtualHost>
</IFModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我使用这个 conf 来代替其他虚拟主机,但看起来这里某处存在错误/错误

【问题讨论】:

    标签: apache redirect dns


    【解决方案1】:

    Apache 2.4 按顺序读取站点配置。 看起来任何 ServerName 或 ServerAlias 中的 url 都没有命中,因此 apache 加载首先读取的站点配置是 diff.domain。

    我最终添加了代表我想要的 url 的 ServerName 并将其重定向到我想要的站点。

    这样我可以确定页面的去向。

    CNAME 指向 IP,在这种情况下它与 A 记录没有什么不同。

    现在我知道更多了。希望这对将来的人有所帮助;-)

    【讨论】:

      猜你喜欢
      • 2021-06-05
      • 2016-07-16
      • 2020-04-15
      • 2016-03-26
      • 2023-03-27
      • 2014-02-17
      • 2018-07-08
      • 2014-01-19
      • 2014-04-11
      相关资源
      最近更新 更多