I am creating php front controller. this is my .htaccess
file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (.*) controller.php [L]
</IfModule>
This code redirect all url to the controller.php
. I need to avoid redirect index.php
to the controller.php
. All other urls should redirect to the controller.php
.
You can use the following syntax to make an exception:
RewriteRule name_of_page_to_exclude.php - [L]
The dash (-
) is important. The [L]
makes sure that if this rule is triggered, it's the last one that will be processed. So naturally, you'll need to place it near the top of your .htaccess
file, before the rule in your question:
RewriteEngine on
RewriteRule name_of_page_to_exclude.php - [L]
RewriteRule (.*) controller.php [L]
The documentation has the following to say:
- (dash) A dash indicates that no substitution should be performed (the existing path is passed through untouched).
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