For the sake of SEO is better to have one URL for each post or article on your site, like having two uris respond with the same content can lead to duplicate content and is penalized by search engines, especially Google, which is the largest by far.

Therefore, if you’re using Nginx and want to remove the trailing slash at the end of every URI in your site.

So if someone writes:

http://yoursite.com/ will be automatically redirected to http://yoursite.com

Here is the code needed to put it in your nginx.conf.

rewrite ^/(.*)/$ /$1 permanent;

That goes in the server section so something like this:

server {
listen  :80;
server_name  www.yoursite.com;
rewrite ^/(.*)/$ /$1 permanent;
}

Nginx will handle the trailing slashes now.

Page 1 of 11