I am trying to redirect all requests except images, css, javascript to my index.php
from root directory, so user can not access other files like .php
directly.
I have following rules in my .htaccess
file in my website's root directory :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(css|js|png|jpe?g|gif|bmp|txt)$
RewriteRule ^(.*)$ index.php?url=$1 [NC,L,QSA]
In index.php I wrote print_r($_SERVER)
and when I access for example /test
under [QUERY_STRING]
it shows something I don't understand :
array(
..
[QUERY_STRING] => url=index.php&url=test
..
)
My questions are : Why is this happening? and Does this affect website performance?
Note : If I add RewriteCond %{REQUEST_FILENAME} !-f
it shows only url=test
, but this allows direct access to files, so a removed this condition.