List and Detail URL Rewriting
Hi,
I've got a list and detail page at the moment but cannot seem to get the URL to rewrite using .htaccess.
At the minute I have this code within my .htaccess.... RewriteRule ^windows/([a-zA-Z0-9-/]+)$ /windows?s=$1 [L]
And the link within the list template is... <a href="/<perch:content id="slug" type="slug" />">
Could any body shed some light on where I am going wrong here? Also, what would be the best way of getting the rewrite into the Title tag?
Thanks for your help
Does changing the link to this help?:
<a href="/windows/<perch:content id="slug" type="slug" />">
Unfortunately not, it brings me back a 500 Internal Server Error
Hmmm… Thought it'd be the directory thing. I'm clutching at straws now… :P
Did you include this before the rewrite rule:
RewriteEngine On
Yeah it's thrown me too!
The RewriteEngine On is at the top of the .htaccess file too
Is the issue the link being wrong or the URL not rewriting to the correct file?
Hi Drew,
The issue is the rewriting - if I leave everything as it was when I first set it up I could access the detail page
What error are you getting at the moment? Have you checked your server error logs for the message?
I'm not getting any errors as such just a page not found
A 404 status code?
Yes that's correct
Does
/windows?s=$1
exist? I seems like it should be/windows/index.php?s=$1
or similar.Wouldn't /windows/index.php?s=$1 mean that the page is placed within the folder 'windows' though? Was trying to keep all files within the root of server
Maybe this would do it, in that case:
^windows/([a-zA-Z0-9-/]+)$ /windows.php?s=$1 [L]
Unfortunately that doesn't work either. I will have to look into alternative ways of doing this
Where is the file? Is it
/windows.php
?I'm sure it's simple to fix, but you're not sharing much information to enable us to help you well.
I have a page called windows.php which is in the route - this is also using a rewrite to remove the .php off the end of the address.
I then have a list and detail page of which the list page looks like the following...
As well as the list my .htaccess reads the following...
The end result should be that I click onto the link within the list and then the detail page should come up as the folllowing...
'website.co.uk/[slug]' instead of the current 'website.co.uk/windows?s=$1'
Try putting
RewriteRule ^/([a-zA-Z0-9-/]+)$ /windows.php?s=$1 [L]
just after theRewriteEngine On
line. If that doesn't work, move it down a line, try it and keep doing that. I suspect it's because there's no file called windows.php because the .php bit is being removed further up the file. Worth a shot :)Still getting nothing from that unfortunately.
Try moving it up to just below your
RewriteEngine On
statement. The rules match in order.That doesn't seem to solve the problem either.
I have tried both windows and windows.php in the following...