I have this .htaccess
I want when I enter exemple.com/home
it will open file home.php
and login same thing else it will open hani.php
RewriteRule ^home$ home.php [L]
RewriteRule ^login$ login.php [L]
...
RewriteRule ^([^\/]+)$ hani.php?link=$1 [L]
My problem When I go home or any other it will open hani.php
Please I want a good solution because I have many pages
Problem is that your last rewrite is unconditional and is rewriting after other rewrites before that have finished thus sending everything to hani.php
.
There are 2 solutions (use any one):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ hani.php?link=$1 [L,QSA]
home.php
or any request containing dot doesn't match the pattern:RewriteRule ^([^/.]+)/?$ hani.php?link=$1 [L,QSA]
Please note that there is no need to escape /
in regex patter in mod_rewrite
.