我的服务器上有三个网站。我的主页 gamenotify.net 运行良好。我的其他两个网站在 www 和非 www 网址之间重定向过多。我的 vhost 文件与我的主页相同。我只是复制了它并替换了文件夹名称和网页名称。
我的主页配置文件
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.gamenotify.net;
set $base path/nginx/sites;
root $base/gamenotify;
# SSL
ssl_certificate path/gamenotify.net/fullchain.pem;
ssl_certificate_key path/gamenotify.net/privkey.pem;
ssl_trusted_certificate path/gamenotify.net/chain.pem;
# HSTS
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
# security
include nginxconfig.io/security.conf;
# index.php
index index.php;
# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# additional config
include nginxconfig.io/general.conf;
include nginxconfig.io/gamenotify.net.wordpress.conf;
# handle .php
location ~ \.php$ {
fastcgi_pass php-fpm;
include nginxconfig.io/php_fastcgi.conf;
}
}
# non-www, subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .gamenotify.net;
# SSL
ssl_certificate path/gamenotify.net/fullchain.pem;
ssl_certificate_key path/gamenotify.net/privkey.pem;
ssl_trusted_certificate path/gamenotify.net/chain.pem;
return 301 https://www.gamenotify.net$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .gamenotify.net;
include nginxconfig.io/letsencrypt.conf;
location / {
return 301 https://www.gamenotify.net$request_uri;
}
}
我的 wordpress 配置只是为了隐藏某些文件和文件夹。
相比之下,我的第二个页面配置文件
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.fotobox-mettingen.de;
set $base path/nginx/sites;
root $base/fotobox;
# SSL
ssl_certificate path/fotobox-mettingen.de/fullchain.pem;
ssl_certificate_key path/fotobox-mettingen.de/privkey.pem;
ssl_trusted_certificate path/fotobox-mettingen.de/chain.pem;
# HSTS
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
# security
include nginxconfig.io/security.conf;
# index.php
index index.php;
# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# additional config
include nginxconfig.io/general.conf;
include nginxconfig.io/fotobox-mettingen.de.wordpress.conf;
# handle .php
location ~ \.php$ {
fastcgi_pass php-fpm;
include nginxconfig.io/php_fastcgi.conf;
}
}
# non-www, subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .fotobox-mettingen.de;
# SSL
ssl_certificate path/fotobox-mettingen.de/fullchain.pem;
ssl_certificate_key path/fotobox-mettingen.de/privkey.pem;
ssl_trusted_certificate path/fotobox-mettingen.de/chain.pem;
return 301 https://www.fotobox-mettingen.de$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .fotobox-mettingen.de;
include nginxconfig.io/letsencrypt.conf;
location / {
return 301 https://www.fotobox-mettingen.de$request_uri;
}
}
我的第三个页面有相同的配置和相同的错误。只有我的第一个页面运行良好。现在我的第二个配置的错误在哪里?为什么我得到这么多的重定向?
感谢您的帮助
答案1
好的,我找到了问题所在。感谢 Richard。我的问题是 wordpress 配置错误。所以我陷入了无限循环。
必须更改数据库中网站标题和 URL 的一些条目。
谢谢<3