1

Building my first PHP site and need some help.

Trying to make it so that the domain name will be used for a directory. Since I know this is a very broad question, the following will be the example of what I have and what I need.

$domain = $_SERVER['HTTP_HOST'];

if ($domain == 'website.com' || $domain == 'www.website.com') {
    $domain = 'Website';
    include ('Website/variables.php') ; } 
else { 
    $domain = 'Other';
    include ('Other/variables.php') ;
} 

Now, what I need it to do is be able to place the $domain inside of an

link href="css/custom.css" rel="stylesheet"

So what it should end up doing is actually using the $domain named folder like so

link href="$domain/css/custom.css" rel="stylesheet"

No matter what I try to do, I just can not get my site to read into the directory of the domain that it is in which is stopping my CSS from working.

Any help would be appreciated.

1
  • 1
    <link href=“<?php echo $domain; ?>” rel=“stylesheet”> Commented Jan 18, 2016 at 17:03

2 Answers 2

1

Try

echo "<link href=' " . $domain . "/css/custom.css' rel='stylesheet'>";
Sign up to request clarification or add additional context in comments.

7 Comments

For some reason, this just isn't working. Although I do see why it should.
Folder structure index.php siteone dir custom.css So your code should work, but it doesn't. That or I'm just screwed up somewhere else. (Which is most likely the case)
Why are you setting $domain to 'Website' or 'Other'? This might be why your css is not working. Also I wouldn't suggest to do this in the first place but I hope I've helped you.
I actually have 4 different websites. Each one has its own custom CSS and Images, so I put the site related items inside their own directory.
Could you explain a bit more? If you really have 4 different websites why does it go to the same file?
|
0

Also you can do as..

<link href="<?php echo $domain; ?>/css/custom.css" rel="stylesheet">

Same thing only....

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.