tglawe
New Member
Hallo zusammen,
leider habe ich ein etwas merkwürdiges Problem auf Unterseiten von Wordpress: Die funktionieren sowohl mit als auch ohne Trailing Slash. Wordpress erzeugt die Permalinks mit abschließendem Slash, die Seiten lassen sich aber auch ohne aufrufen.
Idealerweise sollte NGINX alle aufrufe ohne Trailing Slash weiterleiten an die URL mit Trailing Slash, also rewrite ^([^.]*[^/])$ $1/ permanent;
Das funktioniert aber irgendwie nicht.
Im Betrieb Plesk 17.8, PHP 7.2.10 läuft als FPM Anwedung bedient über NGINX.
leider habe ich ein etwas merkwürdiges Problem auf Unterseiten von Wordpress: Die funktionieren sowohl mit als auch ohne Trailing Slash. Wordpress erzeugt die Permalinks mit abschließendem Slash, die Seiten lassen sich aber auch ohne aufrufen.
Idealerweise sollte NGINX alle aufrufe ohne Trailing Slash weiterleiten an die URL mit Trailing Slash, also rewrite ^([^.]*[^/])$ $1/ permanent;
Das funktioniert aber irgendwie nicht.
Im Betrieb Plesk 17.8, PHP 7.2.10 läuft als FPM Anwedung bedient über NGINX.
Code:
fastcgi_read_timeout 300;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
if ($ssl_protocol = "") {
rewrite ^/(.*) https://$server_name/$1 permanent;
}
if (!-e $request_filename) { rewrite ^(.*)$ /index.php?q=$1 last; break; }
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^([^.]*[^/])$ $1/ permanent;
# try_files in locations is required to pre-empt the above rewrite
# Security directives of iThemes Security
include "/var/www/vhosts/tobiasglawe.eu/v4.tobiasglawe.eu/nginx.conf";
include "/var/www/vhosts/tobiasglawe.eu/v4.tobiasglawe.eu/wp-content/uploads/wpseo-redirects/.redirects";
# Now the generic stuff which is good for all PHP sites
location = /nginx.conf { deny all; }
location ~* \.(txt)$ { charset utf-8; }
# Pics and Fonts valid 90 Days in Cache
location ~* \.(png|jpg|jpeg|gif|ico|bmp|img|ttf|otf|eot|svg|woff|webp)$ {
expires 4w;
add_header Pragma public;
add_header Cache-Control public;
try_files $uri @fallback;
}
# Zips + PDF valid 4 weeks in Cache
location ~* \.(bz2|exe|gz|pdf|rar||tgz|zip)$ {
expires 4w;
add_header Pragma public;
add_header Cache-Control public;
try_files $uri @fallback;
}
# Media files (large) valid 2 months in Cache
location ~* \.(ac3|avi|flv|iso|mp3|mp4|mpeg|mpg|ogg|qt|rm|swf|wav)$ {
expires 2m;
add_header Pragma public;
add_header Cache-Control public;
try_files $uri @fallback;
}
# Possibly modified content valid 1 week in Cache
location ~* \.(js|css|htm|html|xhtml|xml|dat|doc|docx|dts|ppt|pptx|tar|txt|xls|xlsx)$ {
expires 1w;
add_header Pragma public;
add_header Cache-Control public;
try_files $uri @fallback;
}