A
A
Alexander Protasevich2016-01-19 10:51:54
Nginx
Alexander Protasevich, 2016-01-19 10:51:54

How to remove .php at the end of page URLs?

NGINX how to remove .php at the end of page URLs?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wheelie, 2016-01-19
@alexandr_protasevich

stackoverflow.com/questions/21911297/how-to-remove...

A
Alexander Protasevich, 2016-01-19
@alexandr_protasevich

Thanks https://toster.ru/user/Wheelie everything works.
maybe someone will be interested, here is such a config turned out.

server {
    listen		80;
    server_name	test;
    location / {
      root	/test/www;
      try_files $uri $uri.html $uri/ @extensionless-php;
      index	index.php;
    }
    
    location ~ \.php$ {
      root	/test/www;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }
    
    location @extensionless-php {
      rewrite ^(.*)$ $1.php last;
    }
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question