Our Web site is developed by Laravel and is running on Digital-ocean (ngnix). we are facing an issue about the url's which comes with an extra slash like service/index.php/?parameters=5 and want to remove the slash after index.php I don't know any thing about ngnix. only want to remove extra slash and redirect to right url. wrong url
https://example.com/service/index.php/?main=2
Right url
https://example.com/service/index.php?main=2
service is a directory and contains some php files.
CodePudding user response:
Open NGINX configuration file For the Website
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
you can list all website configuration file
sudo ls /etc/nginx/sites-enabled/
and edit your website file
Remove trailing slash
server {
listen 80;
server_name example.com;
rewrite ^/(.*)/$ /$1 permanent;
}
In the above code, the rewrite statement will redirect all URLs to those without trailing slash.
resource https://ubiq.co/tech-blog/remove-trailing-slash-in-nginx/