I would like to create a routing system where if the http://localhost/directory/file.php
exists but i want the htaccess file stopped the default which means opening/reading the file. In contrast, I would like it to pass to the index.php file. I think it is possible to do this with the below htaccess code and get the variables from the url in the php file.
#.htaccess
RewriteRule ^([0-9]+)$ index.php?page=$1 [NC]
Is it possible to do so? Or is there any better way to do so?
I wanted to do this but I do not know how to prevent the default action. Btw I also wanted to know how some libraries like opencart and laravel do their routing.
For example for a register page, I would like when a user goes to http://localhost/directory/register
the index.php will get the page and display it.