I have a Rewrite rule but i want the rewrite rule to only run when the page is not index.php, I have tried using If statement, all but no avail. My code, what I have tried.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^index$ ./index.php // i did a URL rewrite for removing the .php
<If "%{HTTP_HOST } == 'index'">
// do nothing here else
</If>
<Else> //run the code in the else statement.
RewriteRule ^ profile.php [NC,L]
RewriteRule ^profile/([0-9a-zA-Z]+) profile.php?id=$1 [NC,L]
RewriteRule ^ zprofile.php [NC,L]
RewriteRule ^zprofile/([0-9a-zA-Z]+) zprofile.php?id=$1 [NC,L]
</Else>
I solved it after a lack lustre night, with this simple code below, but I did it with another approach, instead of use if statement, i simply rewrote the pages i knew where on my directory first so any page that does not exist on my directory should be redirected to a particular page with the url being the same.