0

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.

yxlow07
  • 260
  • 1
  • 10
  • Yes…!? Doesn't this work somehow? As a general advice: don't put files which you don't want to be publicly exposed into a public webroot directory in the first place. – deceze Dec 28 '20 at 11:39

0 Answers0