FreeKB - Nginx (Web Server) hide .php extension
Nginx (Web Server) - hide .php extension

By default, the .php extension will show in a web browsers address bar. For example, if you've a page named About.php, the address bar will show


Ensure your /etc/nginx/nginx.conf file has the following.

location / {
    try_files $uri $uri/ @extensionless-php;
    index index.php;

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;

location @extensionless-php {
    rewrite ^(.*)$ $1.php last;



Now, .php will no longer be displayed.


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 05681 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |