3

I want any directory to serve up either index.html or index.php – whether a trailing slash was given or not.

Right now my directories will load when a trailing slash is given, but not without.

# Works
localhost/mydirectory/

# Does not work
localhost/mydirectory

I just want it to work either way. Here is my nginx server block:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www;
    index index.php index.html index.htm;

    server_name localhost;

    try_files $uri $uri/ /index.php?$query_string;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Your help is appreciated. Thanks!

Justin Breen
  • 126
  • 3
  • 11

0 Answers0