Forum Moderators: phranque
http://www.example.com/recalls/CHEVROLET/2000/C%2FK+PICKUPS
This is the code I have:
RewriteEngine on
RewriteRule ^([A-Za-z0-9\+-]+)$ /recalls/?manufacture=$1
RewriteRule ^([A-Za-z0-9\+-]+)/([A-Za-z0-9\+-]+)$ /recalls/?manufacture=$1&year=$2
RewriteRule ^([A-Za-z0-9\+-]+)/([A-Za-z0-9\+-]+)/([^/.]+)$ /recalls/?manufacture=$1&year=$2&model=$3
RewriteRule ^([A-Za-z0-9\+-]+)/([A-Za-z0-9\+-]+)/([^/.]+)/([A-Za-z0-9\+¦\.-]+)$ /recalls/?manufacture=$1&year=$2&model=$3&recordid=$4
Can anybody give me a hint?
Thanks!
[edited by: jdMorgan at 11:20 pm (utc) on Oct. 13, 2005]
[edit reason] example.com [/edit]
Welcome to WebmasterWorld!
You'll need to reverse the order of your rules so that the most-specific rule is first, and then remove the "/" from the negative-match patterns used to extract the model (first two rules below):
RewriteEngine on
RewriteRule ^([a-z0-9\+-]+)/([a-z0-9\+-]+)/([^.]+)/([a-z0-9\+¦\.-]+)$ /recalls/?manufacture=$1&year=$2&model=$3&recordid=$4 [NC,L]
RewriteRule ^([a-z0-9\+-]+)/([a-z0-9\+-]+)/([^.]+)$ /recalls/?manufacture=$1&year=$2&model=$3 [NC,L]
RewriteRule ^([a-z0-9\+-]+)/([a-z0-9\+-]+)$ /recalls/?manufacture=$1&year=$2 [NC,L]
RewriteRule ^([a-z0-9\+-]+)$ /recalls/?manufacture=$1 [NC,L]
Note also that I added the [NC] flag to each rule, making the pattern-match a case-insensitive compare. This eliminates the need to have both "A-Z" and "a-z" in your patterns, and speeds up processing. Also, I added the [L] flag to each rule, so that if the rule matches and is invoked, mod_rewrite rule processing will stop and the content-handler will be invoked sooner.
If possible, you should modify your script so that "/" characters in model names are escaped before being published as links. This will eliminate the need to allow slashes in the parameter patterns above.
Jim