php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74570 Not Found in JS, CSS and IMG files
Submitted: 2017-05-10 20:05 UTC Modified: 2017-05-10 20:20 UTC
From: mariombn at gmail dot com Assigned:
Status: Not a bug Package: Built-in web server
PHP Version: 7.1.4 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mariombn at gmail dot com
New email:
PHP Version: OS:

 

 [2017-05-10 20:05 UTC] mariombn at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/features.commandline.webserver
---
Create a router.php file in the public root of my project that is meant to be an alternative to my .htaccess file when using the built-in PHP web server.
Even using example # 3 of the documentation, none of the exception files such as .png, .jpg or others that I have added as .js and .css are not loaded. If I call them directly through the browser, the Not Found error is displayed, The requested resource /assets/css/bootstrap.min.css was not found on this server.

Test script:
---------------
<?php
if (preg_match('/\.(?:png|jpg|jpeg|gif|css|js)$/', $_SERVER["REQUEST_URI"])) {
    return false;    // serve the requested resource as-is.
} else {
    include "public/index.php";
}
?>

Before, use comando: $php -S 127.0.0.1 public/route.php

Expected result:
----------------
My CSS and JavaScript uploaded successfully

Actual result:
--------------
Not Found
The requested resource /assets/css/bootstrap.min.css was not found on this server.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-10 20:20 UTC] kelunik@php.net
-Status: Open +Status: Not a bug
 [2017-05-10 20:20 UTC] kelunik@php.net
Just verified it works. You're probably not in the right directory. The built-in server uses the current directory as document root by default. You can change the document root by using the -t flag.

$ php -S localhost:8000 -t php-test php-test/index.php
PHP 7.1.3 Development Server started at Wed May 10 22:17:29 2017
Listening on http://localhost:8000
Document root is /home/kelunik/GitHub/kelunik/php-test
                 ^------------------------------------

The used document root is also printed on startup as you can see above.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC