appending relative href link to the current url without javascript

Viewed 185

seems like a very trivial problem but I am unable to figure it out.

I am on page http://example.com/emails

and I would like to add a hyperlink as

<a href="inbox">inbox</a>

this results in a http://example.com/inbox

but I would like it to go to http://example.com/emails/inbox

Obviously I can do that by writing full href link

<a href="emails/inbox">inbox</a>

Other method is using javascript to get the current window url and append href with that.

but I am wondering if there is already a way to handle this simply in html without using javascript just by using some relative url scheme.

1 Answers

If you don't want to use JS for taking the full URL/current page URL then you can use PHP. You can use PHP $_SERVER Superglobal built-in variable to get the current page URL. Here I am sharing 2-references for your better understanding, please go through this link hopefully it will help you. Get the full URL in PHP & Get current page URL in PHP

Related