将 ssl 添加到服务器后出现奇怪的重定向

问题描述 投票:0回答:1

我有一台服务器,上面有一个域站点,我们称之为 lauraswork.co.uk,我最近移动了服务器,并在移动过程中向服务器添加了 ssl。如果我直接访问 https://lauraswork.co.uk 那么该网站可以完美加载。如果我访问 http://lauraswork.co.uk,那么由于某种原因,我会被重定向到 lauraswork.mytestsubdomain.co.uk 并引发 ssl 错误。

这是 *:80 虚拟主机,

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerName lauraswork.co.uk
        ServerAlias www.lauraswork.co.uk

        ServerAdmin [email protected]
        DocumentRoot /var/www/lauraswork.co.uk/public_html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =lauraswork.co.uk [OR]
        RewriteCond %{SERVER_NAME} =www.lauraswork.co.uk
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

这是 *:443 虚拟主机

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerName lauraswork.co.uk
        ServerAlias www.lauraswork.co.uk

        ServerAdmin [email protected]
        DocumentRoot /var/www/lauraswork.co.uk/public_html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/lauraswork.co.uk/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/lauraswork.co.uk/privkey.pem
</VirtualHost>
</IfModule>

这应该没有什么区别,但该网站是 wordpress,但数据库中的任何地方都没有引用 lauraswork.mytestsubdomain.co.uk。

apache ssl server devops
1个回答
0
投票

检查您的 .htaccess 文件。在其中找到 303 规则,它可能会指向您的“lauraswork.mytestsubdomain.co.uk”

© www.soinside.com 2019 - 2024. All rights reserved.