Location Rewrite Issue

Randy Johnson randy at randy.cc
Fri Aug 16 05:01:50 UTC 2019

Here is the locations part of my nginx host file:
server {
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

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

I tried adding the following line in there in a couple different places but
all it does is download the php file.

location /blog {
rewrite ^/blog/([A-Za-z0-9-]+)/?$ /blog-article.php?slug=$1 break;

In addition it does not load the /blog page.  It throws a 404.

I am not quite sure what I need to do to get it working.

Thank You,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190816/bdfb0c6d/attachment-0001.html>

More information about the nginx mailing list