我正在Debian上运行一个Apache2.4.25。有一个网站可通过以下方式访问:
example.de and
www.example.de应该通过信任和.htaccess重写它们,以便:
https://example.de
https://www.example.de这不管用。
这一行由let添加-加密到已启用/000-default.conf的站点中,这是我为将example.de重写为www.example.de而添加的注释行,但不起作用:
RewriteEngine on
# rewrite example.de to www.example.de changed 11.11.2019
#RewriteCond %{HTTP_HOST} ^example\.de$ [NC]
#RewriteRule (.*) https://www.example.de/$1 [R=301,L]
#RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301]
RewriteCond %{SERVER_NAME} =www.example.de
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] SSL-config是用2000默认的-le-ssl.conf编写的:
...
Options -Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
# added 01.04.2019 END
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
allow from all
...
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
Header always set Content-Security-Policy upgrade-insecure-requests
SSLCertificateFile /etc/letsencrypt/live/www.example.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.de/privkey.pem 还有一个带有虚拟主机入口的wordpress.conf,用于端口80和443,实际上包含默认和默认的ssl.conf部分。
下面是用.htaccess编写的:
# BEGIN WordPress
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# rewrite example.de to www.example.de changed 11.11.2019
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301]
#RewriteCond %{SERVER_PORT} !=443
#RewriteRule ^(.*)$ https://www.example.de/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule îndex\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]我看了一下错误日志中的重写条目:针对www或https的重写规则没有出现(日志级调试重写:trace4 4)。
当它只是一个测试服务器重写从http到https的工作方式,现在它的生活和它没有,而使用https直接在浏览器工作( url更改了一个字符和条件重写example.de到www.example.de被添加)。我检查了模块;重新启动了服务器;服务器名= www.example.de,服务器别名= example.de;
我在这里的堆栈溢出中发现了这种情况,但是没有什么对我的情况有效或不适用:https://stackoverflow.com/questions/17853828/redirecting-http-to-https-with-apache
有人能帮忙吗。我解决不了这个问题。提前谢谢。
发布于 2019-11-13 10:32:27
问题解决了,我的一个同事改变了SNI的设置,导致了这个问题。
https://serverfault.com/questions/991408
复制相似问题