50 likes | 72 Views
Sometimes NGINX may show trailing slash in website URLs. Here's how to remove trailing slash from URL in NGINX. #nginx #redirect<br><br>Visit https://ubiq.co/tech-blog/remove-trailing-slash-in-nginx/
E N D
Open NGINX configuration file Open terminal and run the following command to open NGINX server configuration file. $ sudo vi /etc/nginx/nginx.conf If you have configured separate virtual hosts for your website (e.g www.example.com), such as /etc/nginx/sites-enabled/website.conf then open its configuration with the following command $ sudo vi /etc/nginx/sites-enabled/website.conf
Remove trailing slash Add the following rewrite rule in server block as shown in bold. Replace example.com below with your domain name server { listen 80; server_name example.com; rewrite ^/(.*)/$ /$1 permanent; }
Restart NGINX Server Run the following command to check syntax of your updated config file. $ sudo nginx -t If there are no errors, run the following command to restart NGINX server. $ sudo service nginx reload #debian/ubuntu $ systemctl restart nginx #redhat/centos
Thank You Visit for details https://ubiq.co/tech-blog/remove-trailing-slash-in-nginx/