the it-madness

NGINX und Probleme mit trailing slash

by on Mai.27, 2010, under Technik

Leider gibt nginx in der Standardconfig einen Fehler aus, wenn man probiert ein Verzeichnis wie folgt aufzurufen: http://www.adresse.de/forum. Ohne Trailling Slash kommt eine wirre Weiterleitung… Hier die Lösung, einfach in den “server {}” Block einfügen:

#code block added for trailing slash issue solving
server_name_in_redirect off;
optimize_server_names off;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_access group:rw all:r;
create_full_put_path on;
if (-d $request_filename) { rewrite ^(.*[^/])$ $1/ break; }
if ($request_method = MKCOL) { rewrite ^(.*[^/])$ $1/ break; }

#code block added for trailing slash issue solvingserver_name_in_redirect off;optimize_server_names off;dav_methods PUT DELETE MKCOL COPY MOVE;dav_access group:rw all:r;create_full_put_path on;if (-d $request_filename) { rewrite ^(.*[^/])$ $1/ break; }if ($request_method = MKCOL) { rewrite ^(.*[^/])$ $1/ break; }

#If Your problem will not solved from above code then use following code.
#here we are adding trailing slash end of Url
#if ($request_uri ~* “^[\w\-\/]+[^\/?]$”) {rewrite ^(.*)$ $scheme://$host$1/ permanent;}
:

Leave a Reply

Spam protection by WP Captcha-Free

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...