.htaccess mod_rewrite with multiple rules

  • Thread starter Thread starter Ed
  • Start date Start date

Ed

Ed

Soldato
Joined
28 Apr 2004
Posts
4,979
Location
Hastings
Hi,

I'm attempting to create a pseudo-directory based on four querystrings and am struggling to find the right method of mod_rewrite to make it work.

Code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ index.php?county=$1&town=$2&business=$3&id=$4 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ index.php?county=$1&town=$2&business=$3 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ index.php?county=$1&town=$2 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ index.php?county=$1 [L]
</IfModule>
I've tried different flags and even without but cannot get it to work. It's either a 404 or a 500 depending on the flags.

The principle behind it is:

Code:
www.example.com/directory/?county=eastsussex
 www.example.com/directory/eastsussex/
Code:
www.example.com/directory/?county=eastsussex&town=hastings
  www.example.com/directory/eastsussex/hastings/
and so on...

.htaccess works fine when there's one rule and all querystrings are passed. Thing is, I've had this working many years ago before but it's been a long time since I've coded and wondered if any of you bright chaps could see where I'm going wrong.

Thanks for your time.
 
Back
Top Bottom