Assuming the structure of your URLs is always going to be:
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
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
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
11 Jul 2006 15:56 PDT
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.