Forum

Thread tagged as: Problem, Configuration

Ht access and perch

I have created a site for a video production company with Perch everything working well. I have used sub folders and an htaccess to make 'pretty urls'.

ie https://www.shootyou.co.uk/corporate-video/product-demonstration

The link to the pages are a typical list an detail (The list is at corporate-video/index.php the detail at corporate-video/portfolio-detail.php)

Link is

<a href="<perch:content id="slug" type="slug" />">

htaccess is

RewriteRule ^corporate-video/([a-zA-Z0-9-]+)/?$ /corporate-video/portfolio-detail.php?s=$1 [L]


Problem occurred when I needed to do to do a 301 redirect on a page

Redirect 301 /corporate-video/old-page https://www.shootyou.co.uk/corporate-video/new-page

When tested this redirects to:

https://www.shootyou.co.uk/corporate-video/new-page?s=old-page

The pretty url redirect affecting the result of the redirect

Not sure if this is a pure htaccess issue or the way I have set up Perch?

Grateful for any thoughts with this

Phil Wragg

Phil Wragg 0 points

  • 6 years ago
Simon Clay

Simon Clay 127 points

I think I've had a similar issue in the past. I don't think it's connected with Perch.

I think it was to do with where in the htaccess file I had the 301. As I recall, I moved the 301 to before the pretty urls (or after, I'm not sure), which solved the problem.

I hope this might help.

Drew McLellan

Drew McLellan 2638 points
Perch Support

As Simon says, almost certainly to do with the order of your rules. They're processed in order, and you can specify when to stop processing. (Mark a rule as [L])

Thanks both will try

Have tried moving redirects but sadly no joy. Will continue to experiment with the construction of the redirect. Quick question is the creation of 'physical' folders ie /corporate-video/index.php the best approach, is there a smarter way using Perch. Many thanks.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If it's regular Perch and not Runway and you want folders then yes you create actual folders.

I would like to revisit this as it is still causing issues for me. I need to to do some 301 redirects but these as explained are failing. I have had a number of people look at this. Its stopping me using Perch for projects.

Essentially a simple redirect - results in an extra element being added to the URL: ?s=new-page ..i.e.

Redirect 301 /corporate-video/new-page https://www.shootyou.co.uk/video-production/

https://www.shootyou.co.uk/corporate-video/video-and-animation?s=new-page

The conclusion previously was that the 301 is in the wrong position this has been thoroughly tested and is not the case.

1) Perhaps the original rewrite could be done differently? (server Apache 2.2)

RewriteRule ^corporate-video/([a-zA-Z0-9-]+)$ /corporate-video/portfolio-detail.php?s=$1 [L]

I have tried a number of variants of 301 redirect to no avail. Would very much welcome any help. Many thanks

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your host would be the person to ask about this. I have redirects of the exact same nature in my own sites along with rewritten URLs. If your hosting is unusually configured that they don't work then this isn't a Perch thing, and isn't something we're going to be able to change for you.