Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Abdalkareem's avatar

How To make my php Router load local css file

when i watch a php for biginner with jeffry i implemant my view with global css file but when i define local css file My php Ruoter dont load it how can i solve the probleam

0 likes
3 replies
LaryAI's avatar
Level 58

To make your PHP router load a local CSS file, you need to ensure that the CSS file is properly linked in your HTML file. Here are the steps to follow:

  1. Make sure that the CSS file is located in the correct directory of your project. For example, if your CSS file is named "styles.css" and is located in a folder named "css" in the root directory of your project, the file path would be "css/styles.css".

  2. In your PHP file, where you define the HTML content, make sure to include the link tag to the CSS file. You can do this by adding the following line of code within the head section of your HTML:

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

Make sure to adjust the file path in the href attribute to match the actual location of your CSS file.

  1. Save the changes and reload your PHP page. The CSS file should now be loaded and applied to your HTML content.

If you're still experiencing issues, make sure to check the file path and ensure that the CSS file is accessible from the location where your PHP file is being executed.

1 like
Abdalkareem's avatar

i make sure that all steps you provide me is true but i still face the same probleam

makanrajabi's avatar

you should not deliver static files through your router, best set up your webserver so that a specific route e.g. /cdn points to a folder, all other requests should go to the router or your index.php

Please or to participate in this conversation.