Google Answers Logo
View Question
 
Q: Apache mod_rewrite expression help ( No Answer,   1 Comment )
Question  
Subject: Apache mod_rewrite expression help
Category: Computers > Programming
Asked by: fiksegts-ga
List Price: $10.00
Posted: 22 May 2004 17:51 PDT
Expires: 23 May 2004 16:48 PDT
Question ID: 350547
I have a question on how to create an apache mod_rewrite rule....


when:

 Mazda-RX-7-Drag-Racing.html 

 is passed through this: 

 RewriteRule ^(.*)-(.*)-Drag-Racing.html$ browse3.php?carmake=$1&carmodel=$2 

 the variables end up being: 

 $carmake = Mazda-RX 
 $carmodel = 7 


 I need it to come out like this: 

 $carmake = Mazda 
 $carmodel = RX-7


How I can rewrite the regular expression to obtain the results I need?

Request for Question Clarification by efn-ga on 22 May 2004 18:46 PDT
What is the general rule you want to apply?

One that would give the result you specified would be that carmodel
may contain hyphens, but carmake may not.  But then you could never
have, for example, "Austin-Healey" as a carmake, which may or may not
be a problem.  (I don't know if your example represents your real
problem or is just made up to demonstrate the problem.)

To put it another way, if you have x-y-z, where x, y, and z do not
contain hyphens, should it always be divided into x and y-z?  Or are
there cases where it should be x-y and z?

--efn

Clarification of Question by fiksegts-ga on 22 May 2004 19:37 PDT
I understand, I have come up with this:

RewriteRule ^([^-]*)-(.*)-Drag-Racing.html$ browse3.php?carmake=$1&carmodel=$2

which demonstrates your point, now I can't have the hypen in the car
make....  the desired result would be that I could have a hypen in
either or both the carmake and carmodel....

and still be able to split them to be used later on....  from what
I've seeing, this may not be possible....
Answer  
There is no answer at this time.

Comments  
Subject: Re: Apache mod_rewrite expression help
From: efn-ga on 22 May 2004 22:20 PDT
 
From your clarification, it looks like you need more than a
RewriteRule can do, perhaps a script that has a table of carmakes.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy