I have an a
tag on my search results page ( www.mysite.com/?search=test
). I would like to simply refresh the page and remove all the $_GET variables from the URL by clicking the <a>
link. Right now I am achieving this with a simple <a href="?">
but that still leaves the URL with a question mark: www.mysite.com/?
.
Is it possible to have an <a>
tag simply clear these variables completely? Or am I stuck with the question mark.
You can try something like this:
<a href="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['HTTP_HOST']}{$_SERVER['REDIRECT_URL']}">Reset search</a>
I figured out a solution. It really should have been pretty obvious but for some reason I didn't think of it.
Simply set the href
to the root directory and rebuild back to the page:
<a href="/blog/">Back</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.