What is the correct way to reference a CSS file from a “header.php” include file? I have a few subdirectories within my site that I would (of course) like to use the same CSS file with, via a header include. However I am unsure of what the general standard is when referencing the css header link in my “inc/header.php” file. Searching around, I haven’t found one agreeable solution. Here is a general example of my site directory:
wwwRoot/
wwwRoot/subDirectoy1
wwwRoot/subDirectoy1/index.php // uses include(../inc/header.php)
wwwRoot/subDirectoy2
wwwRoot/subDirectoy3
wwwRoot/css
wwwRoot/css/style.css // stylesheet
wwwRoot/inc
wwwRoot/inc/header.php // header include that references style.css for whole site
So far I have seen some thing as simple as:
link href="http://wwwRoot/css/style.css" rel="stylesheet" type="text/css"
TO:
link href="http://<?php echo $_SERVER['HTTP_HOST'] . '/css/style.css'; ?>" rel="stylesheet" type="text/css"
And Even seen somewhere where they said to change the include path in the php.ini file, which isn’t an option, because I will not always have access to do this.
So what is the Common Practice for something like this?