Currently, my page URL looks something like so:
https://example.com/eg?page=2
The URL can also sometimes look like:
https://example.com/eg/?page=2
I want to redirect the user to the same page, but without the query string, so that when clicking on a link it will take you to:
https://example.com/eg
I tried using the following href
in an anchor tag suggested in this question:
<a href=".">To home</a>
When clicking on the link, it removes the query string like I want when the current page URL is https://example.com/eg/?page=2
. However, if the page URL is https://example.com/eg?page=2
it takes me to https://example.com
.
Question: Is there some type of directory path (ie url I can use in my href) I can use such that the two above URLs will always remove the query string? I can use javascript, but if a solution without is possible that would be preferred.
Note: I cannot hard code eg
into my href
url as I'm developing a widget which can sit in different environments, so, eg
is subject to change.