Currently I have a controller that handles requests (using friendly URLs). To redirect to this controller I use the following .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ __controller.php?p=$1 [L,QSA]
I then have an index.php that redirects to /home which is the home page (I force this so the home page also uses the controller):
<?php
header('Location: home', true, 301);
exit();
?>
However, I also want it to send to this controller if the file is index.php or if it’s the root domain (as I no longer want the home page to be http://www.test.com/home but rather just http://www.test.com), so each of the following will go through the controller:
http://www.test.com/friendly-url/123/post-topic (currently works)
But also:
http://www.test.com/index.php AND
http://www.test.com
Obviously the last 2 conditions won’t work at the moment as the index.php file exists so the .htaccess won’t send it through the controller.
Are you looking for this ?
Then you don’t need the PHP redirection