Forum
Blog clean URL rewrite rules for nginx
Hey guys.
Our live servers use Nginx while our local dev environment uses Apache - so while we're fine with the blog rewrite rules locally, they don't work (obviously) on the Nginx server.
I understand Drew has been investigating using Nginx for routing either to Varnish or the PHP files; but have you gotten around to converting the rules for the blog URLs to Nginx?
crosses fingers
Thanks!
Ben
When you say "the rules" - what are you trying to do? The rewrite rules you need will depend entire on how you've structured your site.
It's literally the nginx equivalent of RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L] I need.
The site uses the standard /blog/{postSlug} setting.
Which version of nginx are you using?
It's version 1.6.2
I guess it'd be something like
but that's just from looking at the documentation. I've not tested it.
Thanks Drew.
We tried that but it didn't work properly. The blog page was visible, but the posts weren't.
So we played around a little more:
As it stands, we can get either the blog page or the post page working, but not both at the same time.
Any ideas?
You're asking in the wrong place for support for nginx. I've tried to offer a bit of help, but this really isn't my area.
Thanks for your help Drew; it's much appreciated. I'll keep digging. Once I find the fix, I'll let you know so you can put it in the docs :)
Ben, or anybody for that matter, do you have a working nginx solution for the simple blog rewrite rule please?
I have made a working solution for NGINX rewriting. I have altered the way it works for the Events app, but you could apply this to the Blog:
Here what I'm doing is as follows:
Perch Events index page is in /events/index.php
Perch Events event page is in /events/event.php?s=slug
I'm rewriting /event/slug to point to /events/event.php?s=slug
Notice the singluar event (without the 's'). I found I was getting issues redirecting in the same folder, thats why I used /event/ instead.
So now /event/2016-07-14-penchant-16-gullivers-nq
...directs to /events/event.php?s=2016-07-14-penchant-16-gullivers-nq