Question

I did front controller using the query string.

Ex:

But I need to do it without using query string.

Was it helpful?

Solution

in .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    (.*) controller.php    [L]
 </IfModule>

This will reroute everything to controller.php; so you can access it like:

http://host/main
http://host/contact_form

Then in controller.php you have to parse $_SERVER['REQUEST_URI'] to extract passed arguments.

Hope that helps..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top