I am trying to build a custom PHP MVC framework, I want to do the following using .htaccess rewrite
localhost/mvc/page1 OR localhost/mvc/page1/
To this
localhost/mvc/index/view/page1
AND
localhost/mvc/blog OR localhost/mvc/blog/
To this
localhost/mvc/blog/index
AND
localhost/mvc/blog/blog1 OR localhost/mvc/blog/blog1/
To this
localhost/mvc/blog/view/blog1
here index and blog are controllers
Below is what I have tried so far
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=index/view/$1 [L,QSA]
This redirects localhost/mvc/page1 To localhost/mvc/index/view/page1
So basically, I want to have different rewrite conditions for different controllers. So when I will add a new controller I will keep adding condition to htaccess file as well.
This is a code behind redirect (URL should not change),. and everything behind localhost/mvc/ should be reflected in GET $_GET['rt'] parameter
How to achieve this??