Location Rewrite Issue

Reinis Rozitis r at roze.lv
Sat Aug 17 20:42:17 UTC 2019


> Thank you.  That was indeed the issue.  Now  I can see the individual blog entries at /blog/slug-of-blog
> 
> but /blog and /blog/ urls are both throwing a 404.
> 
> Is that an easy fix?
>
>> rewrite ^/blog/([A-Za-z0-9-]+)/?$ /blog-article.php?slug=$1 break;


You have to tweak the regex - currently it expects that there will be always '/' after blog and something afterwards.
Depending on what you actually want to pass in the slug something like this might work:

rewrite ^/blog(/.*)? /blog-article.php?slug=$1 last;

Or if the if the first slash is not needed then ^/blog/?(.*)?


(writing out of head so testing required)

rr



More information about the nginx mailing list