![Apache Redirect 正在重定向所有 HTTP,而不仅仅是一个子域](https://linux22.com/image/600436/Apache%20Redirect%20%E6%AD%A3%E5%9C%A8%E9%87%8D%E5%AE%9A%E5%90%91%E6%89%80%E6%9C%89%20HTTP%EF%BC%8C%E8%80%8C%E4%B8%8D%E4%BB%85%E4%BB%85%E6%98%AF%E4%B8%80%E4%B8%AA%E5%AD%90%E5%9F%9F.png)
所有 HTTP 请求(例如http://example.com
)都会重定向到https://redmine.example.com
,但我只希望http://redmine.example.com
被重定向。
000-default
我的配置中有以下内容:
<VirtualHost *:80>
ServerName redmine.example.com
DocumentRoot /usr/share/redmine/public
Redirect permanent / https://redmine.example.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
.
.
.
</VirtualHost>
这是我的default-ssl
配置:
<VirtualHost *:443>
ServerName redmine.example.com
DocumentRoot /usr/share/redmine/public
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
<Directory /usr/share/redmine/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
LogLevel info
ErrorLog /var/log/apache2/redmine-error.log
CustomLog /var/log/apache2/redmine-access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
.
.
.
</VirtualHost>
这里是否存在导致所有 HTTP 请求被重定向到的因素https://redmine.example.com
?
答案1
ServerName
你的第二个中没有<VirtualHost *:80>
;没有它,任何请求都不会映射到该虚拟主机。
如果您希望它成为所有未发送请求的默认值redmine.example.com
,则请将 redmine vhost 放在文件中的默认 vhost 下方。