A file can exist on disk and still return 404 when it sits outside the web server’s document root or the URL contains the wrong path prefix. Start the local server with the same public root used by the deployed site, then build asset URLs from that root.
Last updated: October 9, 2026.
# Project layout:
# myapp/
# src/
# public/
# index.php
# dirmodules/modulename/svg/my-file.svg
cd myapp
php -S 127.0.0.1:8000 -t public
# This file is now available at:
# http://127.0.0.1:8000/dirmodules/modulename/svg/my-file.svg
curl -I http://127.0.0.1:8000/dirmodules/modulename/svg/my-file.svgThe URL does not contain public because that directory is the document root. It also does not automatically contain /myapp; add that prefix only when a reverse proxy or virtual-host rule actually mounts the application there. Use http, not https, unless local TLS is configured separately.
Map the requested URL to the served directory
Read the 404 request path in the browser Network panel and resolve it relative to the configured document root. Check case exactly because Linux containers use case-sensitive filenames. Also confirm that the file is included in the container image or bind mount, not merely present on the host.
The PHP manual explains that the built-in web server serves the current directory unless -t specifies another document root. The server is intended for development and controlled testing, not public production use.
Avoid hard-coded environment-specific prefixes
Use root-relative URLs such as /dirmodules/.../my-file.svg when the application is deployed at the host root. If production uses /myapp/, configure the same base path locally or inject an application base URL into templates. Do not use a Windows or container filesystem path in an HTML src attribute.
When a front controller handles missing routes, ensure that existing static files bypass it. A direct curl -I request helps distinguish server mapping from HTML or browser-cache issues. Continue with reading the current PHP URL, safe PHP file paths, and web application file storage design.