My website runs perfectly when deployed to an Apache server. It relies on this .htaccess
file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /c/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Now I try to do some testing using the PHP 7.2.2 Development Server
on localhost, which I understand does not make use of the .htaccess
file because it doesn't rely on Apache.
I learned that it is possible to create a router.php
script in the site root and then launch the local development server like this:
php -S localhost:8080 router.php
The router.php
script is supposed to handle all the routing that the .htaccess
file would normally handle on the Apache server. I tried using a sample router.php
script found here, but it doesn't work correctly for my setup. I think the problem is that my .htaccess
file utilizes RewriteBase /c/
to provide a new base URL for the rewrite, but the router.php
script does not have a similar base URL. The problem that occurs with the given router.php
script is that it is trying to rewrite all URLs, not just the ones in the new base URL of /c/
.
My question is: How should I prepare the router.php
file in order to handle my specific .htaccess
file noted above?