Forum

Thread tagged as: Question, Configuration, Blog

re-directing blog post

My old site has its blog posts set up like:

https://sitename.com/postname

So I need it so that on Perch those URL's re-direct to:

https://sitename.com/blog/postname

I'v tried stuff like

RedirectMatch ^/post.php?s=$1 /blog/$1

I have something similar working for my portfolio posts (swapping portfolio for detail):

RedirectMatch ^/portfolio/(.*)$ /detail/$1

Which works! but I cant get the blog posts to work.

Kieran Hunter

Kieran Hunter 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there anything about the post name format that would help you match it? It's going to be tough not to get false positives otherwise.

I just want to add '/blog/' inside the URL, otherwise I could just do a manual 303 re-direct on about 25 existing posts?

Is that good practise though?

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you've only got 25 posts, I'd be tempted to add a specific redirect for each.

Otherwise how does your rewrite rule know that /blog isn't a post to rewrite to /blog/blog and so on.