CodeIgniter.htaccess影响表单


CodeIgniter .htaccess Affecting Forms

从URL中删除index.php导致我的表单页面无法接收POST数据。

此表单位于URL上http://localhost/guestbook/

以下表单标签有效:

<form method="post" action="http://localhost/index.php/guestbook/">

这(并将其留空)不起作用:

<form method="post" action="http://localhost/guestbook/">

第一个确实很好,但它将用户看到的URL更改为操作URL——我希望将index.php排除在URL之外。

这是我的htaccess。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1/ [L]

如何将表单提交到重写的URL?

在配置文件中更改

$config['index_page'] = 'index.php';

到这个

$config['index_page'] = '';

可能运行良好

尝试一下可能会有所帮助Haccess文件将为:

<ifmodule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</ifmodule>

并在Confg文件application/config.php中进行更改使$config空白

$config['index_page'] = '';

打开config.php并执行以下操作以替换

$config['index_page'] = "index.php"

$config['index_page'] = ""

只需更换

$config['uri_protocol'] ="AUTO"

$config['uri_protocol'] = "REQUEST_URI"

在HTACCESS文件中放入以下代码

RewriteEngine on
RewriteCond $1 !^(index'.php|resources|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]