Laravel 11 "Forge" Nginx Template Changes to Stop index.php duplicate URLS

Laravel 11 "Forge" Nginx Template Changes to Stop index.php duplicate URLS

Reyt then;

In https://forge.laravel.com/

Go to your server and to the nginx templates tab

Or if the site is already setup, the server, sites tab and edit files > edit nginx configuration.

I would recommend selecting all with CTRL A and backing up the contents to a local file just in case you make a mistake.

Search for this section

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Under it add

# Remove index.php from all urls
if ($request_uri ~* "^/index\.php(/?)(.*)") {
    return 301 /$2;
}

Job Done