0
I created a router.php file in the published root of my project, this file was made as guidance in the PHP documentation for the built-in server. It works as a native change to . htaccess which is not supported by the built-in server.
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif|js|css|)$/', $_SERVER["REQUEST_URI"])) {
return false;
} else {
include __DIR__ . '/index.php';
}
When I use the remote:
php -S 127.0.0.1:8888 public/router.php
to start my server, it does not load CSS and Avascripts showing error:
Not Found
The requested Resource /Assets/css/bootstrap.min.css was not found on this server.
Someone has been through a similar situation?
I’m using php7.1 on Windows but I’ve already tested version 5.6 and the same thing happens.
Yes, I know that, but the file reference URL is with the port: <link href="http://127.0.0.1:8888/Assets/css/bootstrap.min.css" rel="stylesheet"> And the error even happens by calling the complete file path (which is there) http://127.0.0.1:8888/Assets/css/bootstrap.min.css
– Mario de M. Barros Neto
I updated the answer, tested it here and it seems to be related to the server startup directory.
– Gustavo Jantsch
I tried to do that too. It didn’t help
– Mario de M. Barros Neto
It worked. making the command inside the public folder pointing to a hoarse.php file in this directory worked. The only bad thing is that I didn’t want to leave this file in the public folder, but no problem. Thank you!!!
– Mario de M. Barros Neto
Great, you can start the server with a different root directory type: php -S localhost:8888 -t public/ public/route.php
– Gustavo Jantsch