Project

General

Profile

set request header to HTTP["url"] before rewriting

Added by about 16 years ago

I am using url-rewrite to have pretty urls in the browser address bar. For eg: /inbox is getting rewritten to /jsp/inbox.jsp.

Is there a way that I can set a request header using to store "/inbox" (ie before rewrite url) so that the jsp code can see what the actual url in address bar is?

I tried adding
setenv.add-request-header = (
"X-RW-URL" => $HTTP["url"]
)

but this gives a parsing error in config file


Replies (3)

RE: set request header to HTTP["url"] before rewriting - Added by icy about 16 years ago

There are multiple ways to get the original url in your app.
a) if you do 1:1 rewrites like /inbox to /jsp/inbox.jsp, then you already know in your index.jsp that the url was /inbox, don't you?
b) rewrite to e.g. /jsp/inbox.jps?url=$1

There may be others that I'm currently not thinking of ;)

RE: set request header to HTTP["url"] before rewriting - Added by hoffie about 16 years ago

icy wrote:

There may be others that I'm currently not thinking of ;)

Like using the related environment variables (REQUEST_URI comes to mind).

RE: set request header to HTTP["url"] before rewriting - Added by about 16 years ago

@hoffie Can't use REQUEST_URI as that variable has /jsp/inbox.jsp
@icy
a) the rewrites are not 1:1, so can't use this
b) ended up using this solution. I have like 20 rewrite rules. The only tricky part is to make sure that every rewrite rule from now on should include it

thanks.

    (1-3/3)