Answer the question
In order to leave comments, you need to log in
How to force php build-in server to return non-existent static?
I use a built-in server. I want requests for non-existent statics (cms / init.js in my case and others) to be sent to index.php, to process the request directly by php itself to generate init.js
Current config:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Answer the question
In order to leave comments, you need to log in
Figured it out, it turns out the build-in server doesn't support .htaccess. Routing must be implemented using php.
<?php
# routing.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) {
return false;
} else {
include __DIR__ . '/index.php';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question