apache - 使用 SSL 时 VirtualHost 配置(重写)不起作用

标签 apache mod-rewrite ssl https virtualhost

我使用以下指令在 Plesk 中配置我的 VirtualHost:

[vhost.conf]

ServerName www.mydomain.com
DocumentRoot /var/www/vhosts/mydomain.com/httpdocs

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !^.+\.(css)
RewriteCond %{REQUEST_URI} !^.+js
RewriteRule ^(.+)$ /index.php/$1/

<Directory /var/www/vhosts/mydomain.com/httpdocs>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    php_admin_flag safe_mode Off
</Directory>

在我添加 SSL 证书并通过 https 访问服务器之前,这在每种情况下都运行良好.现在,当通过 SSL 调用站点时,重写不再有效。

所以我认为为其他协议(protocol) (https) 加载的配置必须不同于为 http 加载的配置.

然后我发现 Plesk 为两种协议(protocol)使用了两个单独的配置文件。我复制了vhost.confvhost_ssl.conf .现在网站加载正常 https重写工作正常。

但现在当通过 http 访问站点时,重写不再有效.

猫咬尾部似的,我在原地打转,别无选择。

不幸的是,我缺乏配置apache 的经验。我确实假设我的两组规则以某种方式导致了问题,但毕竟它们包含在两个不同的 <VirtualHost> 中。指令。

也许有人知道这里发生了什么以及如何解决它?

最佳答案

我无法告诉您如何修复它,但我可以告诉您如何开始。

仔细查看访问和错误日​​志。在这里阅读:https://httpd.apache.org/docs/2.2/logs.html

有很多工具可以帮助您进行此处和链接页面中描述的调试。

关于apache - 使用 SSL 时 VirtualHost 配置(重写)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20752646/

相关文章:

与 MongoDB 的 PHP 连接无法正常工作并响应 "trying to get property of non value"

apache - XAMPP 默认虚拟主机

ssl - 使用 http :conduit with https4 apache camel

c# - Azure VM 上的双向 SSL 证书交换

PHP 和 Gettext 在我的服务器上不工作

apache - 添加虚拟主机失败: Access Forbidden Error 403 (XAMPP) (Windows 7)

php - 重定向到子目录并总是得到 404 not found in Slim php

regex - .htaccess mod_rewrite 中的百分号

php - Apache - 使用 .htaccess 重写尾随扩展

python - HTTPS设置后无法访问django网站