我们在我们的网络服务器上有两个conf。http://example.com不会重定向到https://www.example.com
HTTP:
<VirtualHost *:80>
ServerName www.example.de
ServerAlias example.de www.example.at example.at www.example.net example.net
RewriteEngine On
RewriteCond %{HTTP_HOST} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}
# Error page is just the index telling about the situation of not being connected
ErrorDocument 404 /index.html
</VirtualHost>
的https:
<IfModule mod_ssl.c>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.example.de
ServerAlias example.de www.example.at example.at www.example.net example.net
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/www.example.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.de/privkey.pem
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ %{REQUEST_SCHEME}://www.%{HTTP_HOST}$1 [R=301,L]
DocumentRoot /var/www/homepage/web
<Directory /var/www/homepage/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/example-ssl.error.log
CustomLog ${APACHE_LOG_DIR}/example-ssl.access.log combined
</VirtualHost>
</IfModule>
当我尝试打开http://www.example.com然后它会被重定向到https://www.example.com
当我尝试打开http://example.com或https://example.com,然后我出现“页面不可用”的错误
我的两个Web服务器上的conf文件有什么问题? 两者都应该重定向到https://www.example.com网址。
不,HTTP_HOST不会包含'off'值...除非您尝试访问'http:// off' – CBroe
我应该在哪里添加这个可以将其设置为关闭的HTTP_HOST? –
为什么不配置apache虚拟主机没有重定向,并从.htaccess文件进行重定向? –