I added following block in my nginx.conf file. You should add following lines in your server { } block.

We Solved trailing slash issue with Nginx server

If you want use URL without ending trailing slash. then use following code.
#code block added for trailing slash issue solving
server_name_in_redirect off;
optimize_server_names off;
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; }
Above code will check if folder is present then fetch data from there. If you have some idea about MKCOL then you will know above code in better way.
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;}
This will add the ending slash to your url.

Written by WPAPI

My name is Purab Kharat, Here is my Personal Blog: digcms.com. Work as an Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

Leave a Comment

Your email address will not be published. Required fields are marked *