Search code examples
php.htaccessurl-routing

GET method in php mvc framework


I am writing a PHP MVC framework from scratch by myself, I use this .htaccess rules to redirect all requests to my bootstrap:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ bootstrap.php?url=$1 [PT,L

Now the problem is I can't use GET method anymore on forms, when I want to submit a search form using GET method the get parameter won't send, but it will work with post but it's not right for a search form.


Solution

  • This is the .htaccess I am using for my own MVC , may be you can try this

    eg usage :localhost/your_webroot/controller/action/?get_parameters=anything

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ your_webroot/index.php?rt=$1 [L,QSA]
    # This denies all web access to your .ini file. 
    <files config.base.ini>
      order deny,allow
      deny from all
    </files>
    <files errorlogs.log>
      order deny,allow
      deny from all
    </files>