Is there a compatible way to write href?

2019-08-04 11:31发布

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.

标签: html anchor href
1条回答
劳资没心,怎么记你
2楼-- · 2019-08-04 11:45

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.

查看更多
登录 后发表回答