Mod Rewrite Help
Hi guys I could do with your help on this one...
I have a php page: directory.php which ultimately could be in the following states.
directory.php?region=REGION
directory.php?region=REGION&county=COUNTY
directory.php?region=REGION&county=COUNTY&town=TOWN
I'm looking to rewrite this to:
www.webaddress.com/REGION
www.webaddress.com/REGION/COUNTY
www.webaddress.com/REGION/COUNTY/TOWN
I have done some simple rewriting in the past but this has just been confusiong me!
Thanks in advance
pr0gr4mm3r posted this at 12:06 — 30th April 2009.
He has: 1,502 posts
Joined: Sep 2006
Try this:
RewriteRule ^([A-Za-z0-9-]+)/?$ directory.php?region=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ directory.php?region=$1&county=$2 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ directory.php?region=$1&county=$2&town=$3 [L]
a_gajic posted this at 13:48 — 30th April 2009.
They have: 71 posts
Joined: Aug 2001
Thanks, I'm trying to get it to work on xampp. I have removed the comment from
LoadModule rewrite_module modules/mod_rewrite.so
in the httpd.conf file. It doesn't seem to be working. Is there anything else that I need to do? Thanks again
pr0gr4mm3r posted this at 16:51 — 30th April 2009.
He has: 1,502 posts
Joined: Sep 2006
Make sure this is at the top of your .htaccess file:
RewriteEngine On
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.