![]() |
form_open adds index.php to path - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: form_open adds index.php to path (/showthread.php?tid=72345) |
form_open adds index.php to path - Fabatka - 12-07-2018 Hi, Using form_open('your/path') adds the index.php to the absolute path in the final HTML while using base_url('your/path') does not. Posting form data is not working when I use .htaccess to remove index.php from the path AND index.php is part of the absolute path. I suggest removing index.php from all CI generated path in the future so all functions will output a path like base_url for consistency. If you have the same problem as I had not being able to post form data using form_open() you can use the following code instead: <form action="<?= base_url('your/path')?>" method="post" accept-charset="utf-8"> I use the following code in .htaccess to remove index.php and redirect: #1) redirect the client from "/index.php/foo/bar" to "/foo/bar" RewriteCond %{THE_REQUEST} /index\.php/(.+)\sHTTP [NC] RewriteRule ^ /%1 [NE,L,R] #2)internally map "/foo/bar" to "/index.php/foo/bar" RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L] RE: form_open adds index.php to path - kaitenz - 12-12-2018 (12-07-2018, 02:56 AM)Fabatka Wrote: Hi, Did you check your config.php file? Set this to your config file: PHP Code: $config['index_page'] = ''; Also, I suggest using form_open if you have CSRF enabled. |