Forum

Thread tagged as: Question, Runway, Blog

Runway rewrite/tokens

I am trying to create some rewrite rules when using Perch Runway for my blog articles, so I can have URLs which look like https://sitename.com/article/article-name/, where they are currently https://sitename.com/article?s=article-name.

I've used Perch in the past and my (admittedly very limited!) knowledge of rewrite rules would lead me to do something such as...

location /article {
    rewrite ^/article/([a-zA-Z0-9-/]+)$ /article?s=$1 last;
}

...in my server config, however this is bringing me back 404s and I'm also wondering if Runway's built-in routing using tokens and named segments would help me out here?

I'm not amending the Blog app's existing slug creation in any way, but adding a route of /article/[slug:s]/ to my article again gets me back 404s?

Alex Ryans

Alex Ryans 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you should use Runway routes for this. I'd expect a route like the following:

article/[slug:s]

If that's not working, turn debug on and let me know what it outputs.

Hi Drew,

All seems to be well now - I removed the trailing / from my route and pages are resolving correctly. Thanks for your help (as always!).