I created a dir named "test", and inside this dir, i created 3 files: 1.jpg, 2.html and 3.php. If i run php -S localhost:80
and try to visit localhost/3.php, it works. But if i visit 1.jpg or 1.html, or any file that is not a php, it gives me a 404 not found error. I'm using PHP 7.1 NTS on Windows 10. I tried with PHP TS and PHP 7.2 but the error persists.
Asked
Active
Viewed 947 times
8

André
- 185
- 6
-
What do you mean with "mixing up the file extensions"? – André Dec 01 '17 at 23:27
-
I'm 100% sure i'm not doing this. – André Dec 01 '17 at 23:28
-
if its 404 thrown, make sure the image and html file are actually there – Rotimi Dec 01 '17 at 23:29
-
Believe me, dudes, the files are in there and i'm not visiting 1.php instead of 1.jpg. – André Dec 01 '17 at 23:30
-
Like i said, 3.php and any other php file is ok. So i assume i'm executing the command in the right directory. I'm going to post some prints. – André Dec 01 '17 at 23:33
-
I updated the question with the print. – André Dec 01 '17 at 23:37
-
@André The issue may be caused by the accented e in your file path, please test in a different location. https://stackoverflow.com/questions/33150112/why-does-php-built-in-web-server-not-serve-file-called-%C3%A9-txt-on-windows – Jacob Mulquin Dec 01 '17 at 23:43
-
@mulquin, you are an angel. I'm changing my windows username right now. Do you want to write an answer so i can accept it as the best answer? – André Dec 01 '17 at 23:47
-
@André Sure, thanks for taking the time :) – Jacob Mulquin Dec 01 '17 at 23:48
2 Answers
5
The issue may be caused by the accented e in your file path, please test in a different location. Why does PHP built-in web server not serve file called é.txt (on Windows)

Jacob Mulquin
- 3,458
- 1
- 19
- 22
1
I had a similar problem: my php page would display fine but no other page, including images on the php page would be served. The problem was asking the php development server to serve a specific page:
php -S 127.0.0.1:8000 myPage.php
Rather than:
php -S 127.0.0.1:8000
In the later I have to include myPage.php
in the url, but images and other files now display.

user1794469
- 228
- 4
- 17