Welcome! Log In Create A New Profile

Advanced

RE: Location Rewrite Issue

Reinis Rozitis
August 17, 2019 04:44PM
> 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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Location Rewrite Issue

Randy Johnson August 16, 2019 01:04AM

RE: Location Rewrite Issue

Reinis Rozitis August 16, 2019 05:16AM

Re: Location Rewrite Issue

Randy Johnson August 16, 2019 01:02PM

RE: Location Rewrite Issue

Reinis Rozitis August 17, 2019 04:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready