Forum

Thread tagged as: Question, Configuration, Hosting

Trying to create a url rewrite for a list/detail page

I'm trying to create a url rewrite rule for the detail page in a list/detail scenario, similar to what I use for blog.

The list page is /case-studies/case_studies.php

The detail page is /case-studies/case_studies_detail.php

With the php slug, a typical url looks like this: https://my-site.co.uk/case-studies/case_studies_detail.php?s=my-case-study-title

I'm trying to rewrite this so that it appears in the browser as https://my-site.co.uk/case-studies/my-case-study-title

My .htaccess file contains these lines:

RewriteEngine On

# Exclude the Perch CMS directory from any rewrites
RewriteRule ^admin - [L] 

# Rewrite for case studies list/detail page
RewriteRule ^case-studies/([a-zA-Z0-9-/]+)$ /case-studies/case_studies_detail.php?s=$1 [L]

# Rewrite for SEO friendly url
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
RewriteRule ^preview/$ /preview/post.php?s=$1 [L]

The blog rewrite works fine, the case-studies rewrite doesn't. It just doesn't seem to take effect, I still see the php slug (the page navigations from the list page to the detail page work fine).

The live site is here: https://downing-ip.uk/case-studies/case_studies.php

I'd appreciate any insights... Thanks

Nigel Harding

Nigel Harding 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This isn't something we can help with (our solution is to use routes) but I'll leave it here in case any other users want to chip in.