Skip to content
PHP Logo

How can one prevent the addition of index.php?page for every folder in a PHP project when using URL rewriting?

To prevent the addition of index.php?page for every folder in a PHP project when using URL rewriting, you can use a .htaccess file to rewrite the URLs. This file should contain rules to redirect all requests to a single PHP file, which will then handle the routing based on the requested URL.

php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L]