Add trailing slash when it's missing in nginx

Posted by vvanscherpenseel on Server Fault See other posts from Server Fault or by vvanscherpenseel
Published on 2013-10-29T19:16:01Z Indexed on 2013/10/30 9:57 UTC
Read the original article Hit count: 248

Filed under:
|
|
|

I'm running Magento on Nginx using this config: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento.

Now I want to 301 all URLs without trailing slash to their counterpart that includes a trailing slash. For example: /contacts to /contacts/.

I've tried virtually all the nginx directives on this I could find, but to no avail. For example, the directive specified in nginx- Rewrite URL with Trailing Slash leads to a redirect to /index.php/.

Which directive should I add and where?

© Server Fault or respective owner

Related posts about nginx

Related posts about rewrite