我有一个在 Ubuntu 上运行的 apache2 服务器,我正在玩弄它来提高我的系统管理员技能。我一直在尝试在整个站点中使用 HTTPS 设置网络服务器。目前,如果我去https://mysite.com它工作得很好。我尝试了一些不同的重定向规则,以使所有到该站点的连接都强制使用 HTTPS,但我没有运气。谁能在这里指出我的错误?
httpd.conf:
NameVirtualHost *:443
<VirtualHost *:443>
ServerName mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
SSLEngine on
SSLOptions +FakeBasicAuth -StrictRequire +ExportCertData
SSLCertificateKeyFile /etc/ssl/crt/myserver.key
SSLCertificateFile /etc/ssl/crt/mysite_com.crt
SSLCertificateChainFile /etc/ssl/crt/mysite.ca-bundle
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig Options FileInfo Limit
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<IfModule !mod_rewrite.c>
LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
端口.conf:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
任何帮助是极大的赞赏!