I developed a small custom MVC framework for my website. it’s index.php check $_POST[‘page’] & $_POST[‘subpage’] and includes related php file for specified parameter.
Ex: index.php?page=foods (this includes view/foods.php)
Ex: index.php?page=foods&subpage=pizza (this includes view/foods/pizza.php)
Now I want to clean my URLS using .htaccess. I tried few methods to pass second parameter. But I failed. This works fine…
RewriteEngine on
RewriteRule ^([^/\.]+)?$ index.php?page=$1 [L]
But when i tried to pass second parameter its not working fine. This one change css/js/iamges path.
RewriteEngine on
RewriteRule ^([^/\.]+)?$ index.php?page=$1
RewriteRule ^([^/\.]+)/([^/\.]+)?$ index.php?page=$1&sub=$2
If you use the QSA (Query String Apend) flag, you can simply pass the entire request string to an index file –
So your rule would look similar to this –
In your index file you can
.explode()by slashes –And/or use the built in
parse_url()function – http://www.php.net/manual/en/function.parse-url.php