Rewrite URL on client browser
Added by Long Nguyễn Đức over 9 years ago
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?
Replies (5)
RE: Rewrite URL on client browser - Added by Alex V over 9 years ago
I've just tested using.
Wt::WApplication::setInternalPath();
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
app->setInternalPath(foo);
turns the url into /foo
but if I request /foo?bar=1&var=3
app->setInternalPath(foo);
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.
http://stackoverflow.com/questions/16941104/remove-a-parameter-to-the-url-with-javascript
and use doJavascript() or require() from wt
RE: Rewrite URL on client browser - Added by Long Nguyễn Đức over 9 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 over 9 years ago
Hey Long,
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?
Regards,
koen
RE: Rewrite URL on client browser - Added by Marcelo Antunes over 4 years ago
sorry to post so many time after the last post, you already implemented a solution to that question?
Regards