Google Answers Logo
View Question
 
Q: simple mod_rewrite help ( No Answer,   4 Comments )
Question  
Subject: simple mod_rewrite help
Category: Computers > Internet
Asked by: webguy123-ga
List Price: $20.00
Posted: 03 Oct 2005 11:46 PDT
Expires: 14 Oct 2005 14:07 PDT
Question ID: 575846
Ok, This is what I am trying to do

I have a path:

http://localhost/profile.cfm?id=4539872

I want to be able to hit the URL using the following path (or any
other 8 digit userID):

http://localhost/4539872

Here is my mod rewrite rule:

      Options +FollowSymLinks 
      AllowOverride None 
      RewriteEngine On
      RewriteBase /
      RewriteRule ([0-9]+) profile.cfm?id=$1 [QSA,L] 

The above rule works, but all the images will not load on the pages.
If I add a directory in front, the rule works AND images load. Like
this:

RewriteRule /somedirectory/([0-9]+) profile.cfm?id=$1 [QSA,L]


How do I modify this rule so I do not have to add a fake extra directory in
the path I dont need to get the site images to load?
Answer  
There is no answer at this time.

Comments  
Subject: Re: simple mod_rewrite help
From: vladimir-ga on 14 Oct 2005 07:53 PDT
 
Try adding "^" and "$" around the first regular expression, like so:

RewriteRule ^([0-9]+)$ profile.cfm?id=$1 [QSA,L]

Those are anchors that match the beginning and ending of the string, respectively.
Subject: Re: simple mod_rewrite help
From: webguy123-ga on 14 Oct 2005 10:16 PDT
 
Ok, I had a feeling it was something like that.

So, if I wanted to allow alpha characters and numeric mixed combos
from the same path, I would do:

RewriteRule ^([0-9a-zA-Z]+)$ profile.cfm?id=$1 [QSA,L]

correct?
Subject: Re: simple mod_rewrite help
From: vladimir-ga on 14 Oct 2005 10:59 PDT
 
Yeah, that ought to do it.
Subject: Re: simple mod_rewrite help
From: webguy123-ga on 14 Oct 2005 13:17 PDT
 
Thanks vladimir. Post an answer comment so I can process.

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