Reputation: 25
I am trying to use a CSS stylesheet that is up 2 directories and inside another folder:
--project
--css
--main.css
--views
--shop
--products.php
I need to go from products.php to main.css
As far as I'm aware, it should be ../../css/main.css
. but it doesn't work, any help would be appreciated, I'm using Chrome if that makes a difference.
<link rel="stylesheet" type="text/css" href="../../css/main.css"/>
Upvotes: 0
Views: 1174
Reputation: 336
Normally you would place your CSS and JS files in the "webroot" folder of your application. This is the location that your end users will be able to access. Inside this folder would also be the entry point for your PHP application.
So when I connect to www.example.com, I am connecting to their webroot folder: project/webroot/index.php and their CSS could be in: project/webroot/css/main.css
This is done for security as allowing an end user to traverse through your source files will likely reveal vulnerabilities (such as a database address, username and password!).
Keep in mind when making files accessible they need to be available from the client, not just the server!
Upvotes: 2