So here is what I am trying to do. I have a simple structure and I use mod rewrite to rewrite URLs so that they point to the correct files. I have a process folder that is inside the web folder (the web folder has all the actual site files, such as images, css, etc.).
This works fine, but now I'm trying to make a default.php file to handle forms. The file works fine if I point to its form, but I want it to be able to point the form to the corresponding file, and if the file is missing, then it uses default.php
Forms are created by the class, and the action is set to the process / {ID OF FORM} .php. The idea is that anyone can create a form using the class, and if they donβt need to do anything special, the default.php file will handle the form.
I understand that I can simply set the form class to always use default.php, and then in the default.php file, I can check if the corresponding file comes out. If so, then use this file if it does not continue processing the form, but I'm still interested to find out if something like this will work on rebuilding the mod:
RewriteRule ^process/([^/]*) /web/process/$1 RewriteCond %{DOCUMENT_ROOT}/web/process/$1 !-f RewriteCond %{DOCUMENT_ROOT}/web/process/$1 !-d RewriteRule ^process/([^/]*) /web/process/default.php [L]
php .htaccess mod-rewrite
Carlos Rodriguez
source share