Search code examples
htmlhref

html href to one page from different folder


I have edited this question:

At root, I have a working folder F (root/F), under F there is a folder B (root/F/B).

I have a folder A contains a php file a.php (root/A/a.php), containing a link to folder B: <div><a href="B/">link</a></div>

In F, there is an index.php (root/F/index.php) includes the a.php in it, so index.php has a link to folder B;

There is a folder C under folder F. In C, there is another index.php (root/F/C/index.php), which also includes the a.php in it. But now the href becomes root/F/C/B/ instead of root/F/B/.

If I update a.php to <div><a href="/B/">link</a></div>, although href in root/F/C/index.php becomes root/F/B, which is what I want, href in root/F/index.php becomes root/B/.

So my question is how to get a universal href in a.php for all the pages in my working folder?

Thanks for helping!


Solution

  • If you use "/F/B" it will always go to "root/F/B".