Question

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.

Was it helpful?

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>

OTHER TIPS

It's worked for me. Just add this into your .htaccess

Options -Multiviews

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

So you can use this URL.

http://localhost:81/mywebsite/public/search?query=ironman

and this too.

http://localhost:81/mywebsite/public/search/ironman
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top