Josh Bedo
Josh Bedo

Reputation: 3462

htaccess and MVC routing

Well i started coding a mini MVC base that I can just use on client websites, which also uses the same type of router class as CakePHP. I currently have the url display like this:

http://localhost/mvc/index.php?page=blog/viewall

Which gets the controller and tells it the function, just like CakePHP index(), view(), and so on.

Now, I'm not sure how I can make the url look like this with .htaccess

http://localhost/mvc/blog/viewall

I was trying to add this in the .htaccess file:

RewriteRule ^(.*)$ index.php?page=$1 [QSA]

Upvotes: 0

Views: 2452

Answers (1)

anubhava
anubhava

Reputation: 785156

Have your redirect rule like this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mvc/index.php/.*
RewriteRule ^/mvc/(.*) /mvc/index.php?page=$1 [QSA,L]

Upvotes: 1

Related Questions