Jules
Jules

Reputation: 14510

Can't reference stylesheet using absolute directory path

I'm trying to link to an external stylesheet using this code:

<?php
    include("/homepages/9/myusername/htdocs/Mobile_Detect.php");
    $detect = new Mobile_Detect();

    if($detect->isiOS()){
        // code to run for the Apple iOS platform.
        echo '<link rel="stylesheet" type="text/css" href="/homepages/9/myusername/htdocs/style.css" />';
    }
?>

Unfortunately, I can't seem to establish a working link to style.css. I've tried this absolute path, as well as an ordinary path, formatted as if it were HTML: href="/style.css", href="style.css", href="./style.css", and every other possibility. What am I doing wrong? How can I make this code work?

Upvotes: 1

Views: 4519

Answers (1)

penartur
penartur

Reputation: 9912

The href attribute of a style tag is processed by a browser. Browser obviously doesn't have access to your server filesystem path /homepages/9/whatever (even more, it will try to load http://yoursite/homepages/9/whatever).

Change the value of href attribute with something browser is able to load (e.g. http://yoursite/media/style.css).

Upvotes: 3

Related Questions