开发者

Problems with links not working on local server

I'm trying to set up my site in Dreamweaver CS5 to 开发者_如何学Cwork with my local server, and I'm having issues with document relative links.

I've got a structure on my HD like this

website
    _Common
         header.php
    _css
        twoColFixRtHdr.css
    index.php

and the same structure mirrored on my local WAMP server, except on the local server the site is in a subfolder, so it's something like www/website/

The problem is this line inside header.php

<link href="../_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />

That looks correct to me pathwise, but on the local server it cannot find that css file from the header.php

If I change it to

<link href="/website/_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />

or

<link href="_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />

It works fine, but I want to use document relative links if I can, any ideas?


This sounds clear to me, since I'm sure that you include the header file in the index.php file. So the path for the css files is set relatively to the index.php.


you may achieve it by several ways. one of them: you can setup a VirtualHost (in httpd.conf) and point your subfolder as root folder for host.


If header.php is being included in index.php, the relative link ../_css/ in header.php won't work because index.php is at the same level as _css.

For all intents and purposes, once it's been included in index.php, to the browser, the content in header.php is now simply part of index.php, so all paths need to be relative to index.php.

Ie:

index.php

/my_include_folder - header.php

/_css - style.css

Once I add <?php include('my_include_folder/header.php); ?> to index.php, the links to css files, js, and hyperlinks in header.php should be relative to index.php.

Hopefully that makes sense.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜