0
Good people, I am making a very simple page, to return to the programming.
Here’s the problem: my php is not loading Css, Img or Js.
Yes, I’ve tried to put the absolute/relative path
My directories:
- test/
- public/
- css
- js
- src/
- header.php
- index php.
- public/
I happen to run there "php -ss localhost:8000 index.php" and try to access the website, it will load normal page, but without any css and without any js.
in my "index.php" occurs a include of "header.php", including css is inserted through html tag:
<link rel="stylesheet" type="text/css" href="/public/css.css" />
I’ve tried too:
<link rel="stylesheet" type="text/css" href="../public/css.css" />
also tried ridiculous things like put any path to see if it gave:
<link rel="stylesheet" type="text/css" href="css.css" />
I’ve tried the relative too:
<link rel="stylesheet" type="text/css" href="public/css.css" />
I tried several things, the relative path also does not work... Anyway, I researched for a couple of days on the Internet and nothing. In every forum is said to use the absolute path, but I’ve used and nothing.
In the terminal, this message appears:
PHP 7.0.19-1+deb.sury.org~xenial+1 Development Server Started at Sat May 13 17:14:49 2017
[Sat May 13 16:49:06 2017] 127.0.0.1:51976 Invalid request (Unexpected EOF)
I’ve reinstalled php, apache2 and everything
Use the Ubuntu 16.04 LTS
It worked with a giant gambiarra here guys...
I did something with slim, to try to put a friendly URL, then I did a single route for a css (As if it was a url for a page, but for . css).
Hence, for example, the "/meucss" route renders the file "meucss.css" as if it were a page.
In the HTML tag to pull the css from there I put only href="/meucss" and it loads the css... But do not apply Stilo, just press
However, there are no conditions, having to put routes for each css/img/js I insert on the page... Someone has a tip?
Valeeu!
An error appears in the browser console?
– Guilherme Nascimento
Only the 404, which is natural because it is not finding the file...
– Matheus
Yeah, I could put the whole log in?
– Guilherme Nascimento
Look, it worked here (don’t ask me why) when instead of "php -ss localhost:8000 index.php" I just used "php -S localhost:8000"...
– Matheus
You’re right, in fact the
sS
in capital letters does not exist according to doc: http://php.net/manualen/features.commandline.options.php, strange that he executed even so– Guilherme Nascimento
But if I run "php -S localhost:8000 index.php" it doesn’t work... To work I have to omit "index.php"
– Matheus
Mathues see if you can understand the explanation
– Guilherme Nascimento