Is there a compatible way to write href?

天大地大妈咪最大 提交于 2020-01-06 03:15:05

问题


For example, in file test.php:

<a href="someting/?start=1">go</a>;

so that no matter where this test.php is, whether in Document_Root/Test/ directory or in Document_Root/Production/ directory, the anchor will point to itself.


回答1:


To write a link that will only change the query string, just use

<a href="?foo=bar">whatever</a>

So if you're at http://the/current/url.php, it goes to http://the/current/url.php?foo=bar, or if you're http://somewhere/else?entire=ly, it goes to http://somewhere/else?foo=bar.



来源:https://stackoverflow.com/questions/873735/is-there-a-compatible-way-to-write-href

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!