As a question says, when I run command php -S localhost:8000
in terminal(after positioning in project root), and after that, I try testing out the URL http://localhost:8000/app.php
, (app.php is my backend file used for route handling and processing fetch requests) and everything works fine, app.php content is shown. However, when I start Apache via Laragon,without running php built-in server, it runs on port 80, and I try testing that aswell with http://localhost/app.php
, but the error I recieve is 404:Not found
. This isn’t happening only to app.php, but to all backend files I want to reach.
Although I think this isn’t much code-related, since I tried mostly with direct URL submit, I will show my fetch request
fetch('/back-end/app.php',{
method:'POST',
headers:{
'Content-Type':'application/json'
},
body:JSON.stringify({
firstName:firstName,
lastName:lastName,
username:username,
email:email,
password:password
})
})
.then((response)=>{
if(response.ok){
return response.json();
}
})
.then((data)=>{
console.log('Response:'+data);
})
.catch((err)=>{
console.error('Error is this:'+err.message, err);
})
My .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /back-end/app.php [QSA,L]
Why is this happening, that backend files are accessible with php built-in server running, but not with Apache?