Post PHP form to non-existing page

Posted on 16th Feb 2014 by admin

The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rewrite. I recently wrote a custom framewok that is loosely based on Codeigniter. To get SEF URL's 'n used a custom 404 page to redirect my URL's to where they should be. An example URL would be www.example.com/search. 'Search' would not be found and the script would go to the 404 page which would then redirect to my controller named search.php which in turn would load the necessary models and finally the views. This all works perfectly.

My problem however is when I use a simple html form that posts to a php file. The action is set as follows action="<php echo $BASEPATH ?>search" this path resolves to the search controller. But the big problem is this file does not exist. So I do get directed to the page, but the $_POST is empty.

Does anyone have any ideas on how to get around this? The other option is to just avoid forms alltogether and use AJAX for everything, but there has to be something that I am missing or can do different.

Other forums