I'm using mod rewrite to access my PHP files in the root directory of my website indirectly. Currently, I have something like this,
RewriteRule ^(blog|about|page3|etc)$ /$1.php [L]
But what I would like to use is
RewriteRule ^(.*)$ /$1.php [L]
So that I wouldn't have to update my .htaccess file whenever I wanna add a new page to my website. The problem with this however is that it affects my subdirectories too. Which makes CSS, javascript, images unaccessable because it redirects to "/dir/example.png.php".
So what is the best solution here?
Try this rule:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule .* $0.php [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With