Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Write Correct Path Of These Files?

Tags:

php

I have an PHP file located here :

/public_html/folder1/folder2/index.php 

and this file requires CSS file located here :

/public_html/folderX/folderY/css1.css

what is the correct path to access that CSS file should I put in the index.php? thanks.

like image 945
Saint Robson Avatar asked Jan 15 '23 05:01

Saint Robson


1 Answers

Assuming that public_html is your root:

<link rel="stylesheet" type="text/css" href="/folderX/folderY/css1.css" />

My personal advice is not to meddle with relative paths; they will only get you into trouble when you start moving your PHP scripts around; or worse, when your code gets included as part of another script and you have no way of knowing where that is.

The same thing could be said for references inside your CSS (images); it's not always immediately obvious that relative paths inside CSS files are taken from the location of that file as opposed to inline CSS, which uses the location of the page.

like image 198
Ja͢ck Avatar answered Jan 26 '23 04:01

Ja͢ck