在 Apache 服务器上使用 HTTPS 不起作用

在 Apache 服务器上使用 HTTPS 不起作用

对于我的服务器 www.tripmatcher,com,我遇到了与为什么 apache httpd 告诉我基于名称的虚拟主机仅适用于启用 SNI 的浏览器(RFC 4366)。我的配置文件位于 /etc/apache2/sites-enabled/default-ssl.conf,如下所示:

<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 www.example.com

        ServerName tripmatcher.com
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^tripmatcher.com
        RewriteRule ^/(.*)$ http://www.tripmatcher.com/$1 [L,R=301]

        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        <Directory "/var/www/html">
        AllowOverride All
        </Directory>

        # 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
</VirtualHost>

<VirtualHost *:443>

ServerAdmin [email protected]

DocumentRoot /var/www/html
<Directory "/var/www/html">
        AllowOverride All
        </Directory>


ServerName tripmatcher.com

ErrorLog ${APACHE_LOG_DIR}/error.log

SSLEngine on

SSLCertificateFile /etc/ssl/tripmatcher.crt

SSLCertificateKeyFile /etc/ssl/tripmatcher.key

SSLCertificateChainFile /etc/ssl/tripmatcher.ca-bundle

</VirtualHost>

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

据我所见,这看起来不错。有人能指出我哪里出了问题吗?问题是当我去https://www.tripmatcher.com,我让页面加载,尽管缺少一些 CSS。但是,当我登录并转到时,说https://tripmatcher.com/matcher我收到“此服务器上未找到所请求的 URL /matcher。”有人能向我解释一下出了什么问题吗?

[2017 年 12 月 10 日星期日 22:23:25.578086] [ssl:warn] [pid 19647] AH02292:Init:基于名称的 SSL 虚拟主机仅适用于具有 TLS 服务器名称指示支持的客户端(RFC 4366) [2017 年 12 月 10 日星期日 22:23:25.580546] [mpm_prefork:notice] [pid 19647] AH00163:已配置 Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.20 OpenSSL/1.0.1f - 恢复正常运行 [2017 年 12 月 10 日星期日 22:23:25.580590] [core:notice] [pid 19647] AH00094:命令行:'/usr/sbin/apache2'

我在日志中看到了这一点。

答案1

只需更改 .htaccess 的顶部即可达到此目的:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.tripmatcher.com/index.php/$1 [R,L]
#RewriteRule

希望这对遇到此问题的人有用。

相关内容