Berkay O.
Berkay O.

Reputation: 65

How can i put the css for all specific php pages

My folders are here: enter image description here

In my header.php there is this code:

 <link rel="stylesheet" href="style.css">

In the index.php i can include like this:

include('header.php') 

I can reach style.css there is no problem.

But, in the product/product.php

include('../header.php') 

I can not reach style.css I can reach the header.php but i can not reach style.css. Because in the header.php, this include code seems that style.css is in the product/style.css, but my style.css is in home folder. How can i reach? Can u help me?

Upvotes: 1

Views: 88

Answers (1)

Ersin Demirtas
Ersin Demirtas

Reputation: 686

The solution is simple the browsers try to request the file relative to the current directory, so just need to add / in the begging of the HREF to make sure you are referring to a file that is in the root.

Solution:

<link rel="stylesheet" href="/style.css">

Upvotes: 2

Related Questions