g1smd

msg:4310006 | 6:39 pm on May 9, 2011 (gmt 0) |
The CSS file is requested by the browser as a URL. The URL is a reference system used outside on the web. Therefore in the link to the CSS file use a URL that begins with a slash and counts, in URL terms, from the root of the site, e.g. href="/css/style.css". Do not use a relative URL, otherwise each page of the site will be looking for a CSS file at a place that is relative to that page... and which will therefore fail to find the CSS file. You could add the protocol and domain name to the CSS link but this will cause extra work if you have a mix of HTTP and HTTPS pages.
|
rocknbil

msg:4310388 | 4:24 pm on May 10, 2011 (gmt 0) |
In addition this gets really important if you are using mod_rewrite for friendly URL's. If you rewrite some request h t t p://www.example.com/my-widget-category/ to a script in a directory /products/script.php The request still appears to come from example.com/my-widget-category/, even when you're in /products/ - the leading slash always fixes this. It's the same for any CSS, JS, Image, or other objects too, always reference with a leading slash. The down side is, it doesn't work locally unless you set up a virtual server of some sort. Not a big deal, but you (generally) have to mod all paths for offline work, update them before deployment.
|
g1smd

msg:4310392 | 4:41 pm on May 10, 2011 (gmt 0) |
With XAMPP installed and running in just a few minutes, everyone should be testing changes to their sites on /localhost/ or /127.0.0.1/.
|
bjassoc

msg:4311520 | 7:24 pm on May 12, 2011 (gmt 0) |
after many years of doing websites, I didn't know that starting a link with / goes back to the root. Exciting! except that I just tried it with php files that I'm using (for first time - converting website built with FrontPage). the file I'm testing is [findajp.com...] which has this Code: <?php require("/includes/navhoriz.php"); ?> not working - it isn't going back to the root for the includes folder, instead looking for the includes folder in the findajp.com/jpnh/ directory. thanks for your help.
|
g1smd

msg:4311534 | 8:11 pm on May 12, 2011 (gmt 0) |
You need to be aware of another thing; "includes" are an internal request within the server, so you need the full internal server path. To be clear, "includes" do NOT use a "URL". URLs are used only outside the server, out there on the web. The URL path begins at the site root not at the internal file system root.
|
bjassoc

msg:4311558 | 9:09 pm on May 12, 2011 (gmt 0) |
I didn't know that. I changed the call to <?php require("/home/bjassoc/public_html/includes/navhoriz.php"); ?> which I think is the full path. I dont understand the error msg: "No such file or directory in /home/bjassoc/public_html/jpnh/rockingham.php on line 102." It's still looking in the folder that's doing the call? thanks again.
|
rocknbil

msg:4311998 | 5:32 pm on May 13, 2011 (gmt 0) |
Try this instead. <?php require($_SERVER['DOCUMENT_ROOT'] . "/includes/navhoriz.php"); ?> Or you could get it from phpinfo() and hard code it, but hard coding it is a lot less flexible. <?php php_info(); ?> <aside>(W.O.W., please do not leave phpinfo.php on your server. Use it, then delete it. It reveals far too much info about your server configuration and is one of the files that hackers look for.)</aside>
|
bjassoc

msg:4312182 | 11:17 pm on May 13, 2011 (gmt 0) |
the call you suggested worked - thanks so much. Don't understand how to do the php_info. I think I was wrong to put my path out there (earlier post) but dont see a way to delete it. too late to edit.
|
rocknbil

msg:4313157 | 4:16 pm on May 16, 2011 (gmt 0) |
That bit of code I posted is a php_info() in entirety, put it in a file and upload to your server. I meant, don't leave **that** on your server - obviously the path you posted is incorrect anyway or it would have worked. :-)
|
|