CSS菜单网址未正确重定向

I created a CSS menu, to use on a PHP site, but now I realised that for example:

From the Home tab (URL localhost/site), all the item links are correct if you hover over them, but now i navigate to "Stock" for example, who's URL is localhost/site/stock... it opens correctly. So from Stock i want to navigate to Sales (localhost/site/sales), the URL of sales become localhost/site/stock/sales and not just localhost/site/sales.

I added this menu only recently, the previous one was working fine, so for a test, i replaced the css menu with the previous one, but to no avail. the problem still persist, so I assume that something else must have changed the behaviour of the links...

I can probably fix this by added " ../ " in front of the menu's URL, but on the other hand. not all items are just one step back.

Your help would be greatly appreciated.

Try using absolute URLs.

When your link is on a page located at localhost/site/stock:

<a href="sales">Link</a> <!-- goes to localhost/site/stock/sales -->

But if you prepend a forward slash, the destination will be absolute, relative to your document root:

<a href="/sales">Link</a> <!-- goes to localhost/site/sales -->

Assuming of course that your document root is localhost/site

More likely your links will have to look something like:

<a href="/site/sales">Link</a>

You're correct in saying you need to add slashes. My suggestion would be to provide absolute links from / to your page:

/site
/site/sales
/site/sales/sale24
/site/stock
/site/stock/secondstockpage
/site/stock/thirdpage

I have changed the menu as you suggested, but now, it works as follow:

if i for example set my menu link to direct to: /site/sales/sold.php so the menu.php file link would look like this:

<li><a href="sales/">Sales</a></li>
    <ul>
        <li><a href="sold.php">Sold Items</a></li>
    </ul>

it would sometime direct to /site/sales/sold.php and the next moment, it repeats the menu's directory like: /site/sales/sales/sold.php

so i removed the sales directory, as its directing there by itself, worked for a little while and now it directs to /site/sold.php which does not exist so it ends up with a 404.

should i specify a siteroute somewhere else?

this is very weird to me. first time i encounter something like this!

Hope my examples make sense!