Bug #66191 [Com]: relative paths are not handled correctly

From: Date: Thu, 28 Nov 2013 18:07:14 +0000
Subject: Bug #66191 [Com]: relative paths are not handled correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182998@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66191&edit=1 ID: 66191 Comment by: jakoch at web dot de Reported by: jakoch at web dot de Summary: relative paths are not handled correctly Status: Not a bug Type: Bug Package: Built-in web server Operating System: Windows PHP Version: 5.4.22 Block user comment: N Private report: N New Comment: Demo: https://www.dropbox.com/s/go5ikn4kvryl6e1/php-server-bug.zip http://localhost:90/application <-- not working http://localhost:90/application/ <-- working Anon, i think you might be right and an implicit redirect would solve this. Previous Comments: ------------------------------------------------------------------------ [2013-11-28 16:31:58] anon at anon dot anon When you browse '/application', the web browser has no way of knowing that 'application' is a directory. It looks like a file in '/'. Consequently, the base URI is '/', so the browser requests resources relative to there. The correct path you should be viewing from is '/application/'. Therefore, it's a web server's responsibility, whenever a directory is requested without a trailing slash, to send a redirect so that it does have a trailing slash. Apparently this vital redirect isn't being sent. I'm not familiar with PHP's built-in web server so I can't say if this missing redirect is a bug in the server or a configuration or user error. ------------------------------------------------------------------------ [2013-11-28 16:13:10] jakoch at web dot de "Browsers interpret relative URLs relative to the current URL ..." The current URL is "http://localhost:90/updater" not "http://localhost:90/". On the screenshot you see, that i get a http code 200 for browsing into the subdir. Then <link href="assets/css/bootstrap.css" rel="stylesheet"> should resolve to http://localhost:90/updater/assets/css/bootstrap.css, but it's requested as http://localhost:90/assets/css/bootstrap.css - logged as "/assets/css/bootstrap.css" - the file is at /updater/assets/css/bootstrap.css. Putting http://localhost:90/updater in front of the href works, but thats not what i want to use, because the page is served with Nginx. And that works... ------------------------------------------------------------------------ [2013-11-28 15:40:23] johannes@php.net These paths have to be resolved b the browser, not PHP as server. Browsers interpret relative URLs relative to the current URL ... ------------------------------------------------------------------------ [2013-11-28 15:22:53] jakoch at web dot de Description: ------------ I believe that relative paths are not handled correctly by the embedded server. I have this in my index.html file: <link href="assets/css/bootstrap.css" rel="stylesheet"> The file resides in /www/application. Served by php -S localhost:90 -t c:\www. When i browse http://localhost:90/application the css is not loaded. The URL is not resolved to http://localhost:90/application/assets/css/bootstrap.css, but http://localhost:90/assets/css/bootstrap.css. Resulting in a resource not found error. The domain/URI of the current document is not taken into account. http://www.w3.org/TR/html401/struct/links.html 12.4.1 Resolving relative URIs 3)"By default, the base URI is that of the current document. The base URI is not the the root of the server. Screenshot: http://i.imgur.com/1KDW42G.jpg ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66191&edit=1

« previous php.bugs (#182998) next »