Google Answers Logo
View Question
Q: Making RewriteRule's ( Answered,   0 Comments )
Subject: Making RewriteRule's
Category: Computers > Internet
Asked by: maperez8-ga
List Price: $15.00
Posted: 09 Jul 2006 11:46 PDT
Expires: 08 Aug 2006 11:46 PDT
Question ID: 744709
I'm traying to make a rewrite rule to go from,CI

My site is build with java, and doesn't need some par like par1=33918458,par2=CI

so... I'd like to rewrite from:,CI

I'll glad if some bady can help me!

Best Regards
Subject: Re: Making RewriteRule's
Answered By: sycophant-ga on 09 Jul 2006 19:21 PDT
Hi Alfredo, 

Assuming the structure of your URLs is always going to be:
(letters)(question mark)(numbers)(comma)(letters)

the following rewrite rule should work:

RewriteRule /servlet/([a-z]+)\?([0-9]+),([a-z]+)      /servlet/$1-$2-$3.html [NC]

- The above needs to be a single line, the space between the last )
and the / of the next section is typically a tab. This rule has been
constructed as case-insensitive, however to make it case sensitive,
simply remove the [NC] from the end and adjust the case of the [a-z]
accordinging. The rule is non-conditional and will apply to all
matching requests.

To work, mod_rewrite will need to be available and active, using the
'RewriteEngine on' directive.

If this doesn't work for you, please let me know, and possibly provide
some additional example URLs to refine the expression.


Request for Answer Clarification by maperez8-ga on 10 Jul 2006 03:41 PDT
Hi ! Sycophant !
Thanks! for answer! but... Didn't work.. 

I Tried with:


And the error was:
javax.servlet.ServletException: Class `hficha-14564147-DNID.html' was not FOUND

(The rewrite rule doesn't rewriten to the format hficha?14564147,DNID

I don't know if with this clause that you send me.. It will became
from hficha-14564147-DNID.html to hficha?14564147,DNID

With Question mark and the comma (without .html)


if it work only to hficha  (like I wish) or it will work to all servlets


and so on...

Thanks ! very much !! for you clarifications !

Clarification of Answer by sycophant-ga on 11 Jul 2006 15:56 PDT
Hi Alfredo, 

I may have misunderstood the direction you wanted the rewrite to work.
The solution I have provided takes a web request for
'hficha?14564147,DNID' and makes it into 'hficha-14564147-DNID.html' -
It seems you are wanting to go the other way...

Try this rule instead:
RewriteRule /servlet/([a-z]+)-([0-9]+)-([a-z]+)(\.html)      /servlet/$1?$2,$3 [NC]

That should take any URL that matches:
Then remove the .html, replace the first hyphen with a question mark,
and the second one with a comma. It is case insensitive (although case
will be retained).

Sorry for the confusion, I hope this is what you need.

There are no comments at this time.

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 with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

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