I’m trying to catch all .php requests so that my visitors won’t be able to see the php magic
I want example.com/home to be redirected to example.com/index.php, but I don’t want direct access to example.com/index.php
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
Although it seems to work at first glance, it doesn’t prevent users from visiting example.com/index.php directly.
How would I solve this?
In reply to an answer:
RewriteRule ^index.php$ / [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^home/?$ /index.php?category=1 [L]
example.com/home outputs example.com/category=1
Try this:
What that will do is, if the user tries to go directly to index.php, it will redirect them to the root of the site. Otherwise, it will run your existing rules, passing anything through to index.PHP.