I got three websites on my server. My mainpage gamenotify.net works well. My other two are getting to many redirects between www and non-www url. My vhost files are identical to my mainpage. I just copied it and replaced the folder names and webpage names.
My main page conf file
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;
}
}
My wordpress config is only to hide certain files and folders.
In comparison my second page config file
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;
}
}
My third page got the same config and the same error. Only my first page works well. Now where is my error on my second config? Why do i get so too many redirects?
Thank you for your help