Rewrite URL on client browser
A client sends a GET request to my server. Now that I handled the request, how can I rewrite the client URL bar to remove the parameter string?
RE: Rewrite URL on client browser - Added by Alex V about 8 years ago
I've just tested using.
it seems to work when there is only one URL parameter and it appears to be broken if there are more than one.
eg: I request /foo?bar=1
turns the url into /foo
but if I request /foo?bar=1&var=3
turns the url into /foo&var=3
I am not sure if setInternalPath is meant to preserve or remove the URL parameters in this case but it looks like a bug either way.
you could implement one of the solutions in this stackoverflow question.
RE: Rewrite URL on client browser - Added by Long Nguyễn Đức about 8 years ago
Thank you for your finding. At first, I thought changing internal path would preserve the whole parameter keys.
Well, this can be done by calling
setInternalPath n times where n is the number of parameter keys.
RE: Rewrite URL on client browser - Added by Koen Deforche about 8 years ago
As creative that may be, I suggest we fix the issue before you rely on broken behavior :-)
Setting/removing internal paths is supposed to preserve parameters. So there is definitely a bug in the described behaviour (what version of Wt was that, Alex?)
I would suggest we create an additional API in WApplication to reset the query string (which works only in HTML5 browsers, but that's plenty good these days). Can you file a bug and/or feature request for this?