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.
References:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html |
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:
hficha-14564147-DNID.html
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)
AND
if it work only to hficha (like I wish) or it will work to all servlets
hficha?14564147,DNID
messanges?14564147,DNID
sent?14564147,DNID
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:
[Letters][Hyphen][Numbers][Hyphen][Letters][".html"]
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.
Regards,
Sycophant-ga
|