I am beginning my journing on php development and i am trying to do my own MVC framework. I have a huge problem whith URLS.

My URL Format:

everything is working fine but per example when i call it like:
http://example.com/index.php, The default Controller is called, no problems with that, but if i call like:


The default Controller is called again, and my script will only load the right controller if index.php is added in the URL like that:

there is a way to always include the index.php in the URLS request, maybe using .htaccess or some function, i tried to do many things but no success

.htaccess files use regular expressions to redirect so a URL like
could be redirected to
using the .htaccess file

#Enable URL Rewriting
RewriteEngine on

RewriteRule ^/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+).html$ //index.php?file=$1&arg2=$2&arg3=$3 [QSA]

so in your example you just need somethingl ike

#Enable URL Rewriting
RewriteEngine on

RewriteRule ^/([0-9a-zA-Z_/-]+)$ //index.php/$1 [QSA]

I haven't tested that code but it should be OK