# HG changeset patch # User Andrey Alexeev # Date 1319635200 0 # Node ID d8a53dda98a7a3c087c1425810ce6f22cfee91c8 # Parent dfc9d4338fefacf60d37be534143d1e71ea5df9b - Adding more faq's diff -r dfc9d4338fef -r d8a53dda98a7 xml/en/docs/faq_trailing_slash_redirect.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml/en/docs/faq_trailing_slash_redirect.xml Wed Oct 26 13:20:00 2011 +0000 @@ -0,0 +1,57 @@ + + +
+ +
+ + +Q: +What is the right way to do a trailing slash redirect for the +requests without a trailing slash in the URI? + + + +A: +If the URI refers to a static file or a directory then nginx +will do the redirect automatically. If it's not a static +content and REQUEST_URI should be proxied to the backends, +the following configuration will work: + + + + +location ~* /[^/\.]+$ { + rewrite ^(.*)$ http://$http_host$1/ permanent; +} + + + + +However, a better way of doing that would be separating +static content and proxying: + + + + +location / { +    index index.php; +    try_files $uri $uri/ /index.php?$args; +} + +location ~ (?^.*/[^/.]+$) { +    return 301 http://$host$url/$is_args$args; +} + +location ~ \.php$ { + ... +} + + + +
+ +
\ No newline at end of file