2015-04-03 82 views
0

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

这种形式是对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?

+0

使用相对路径<形式方法= “POST” 行动= “/留言”> – Tpojka 2015-04-03 23:45:27

+0

@Tpojka这也不能工作。 – coin 2015-04-03 23:56:07

+0

无论POST操作如何,其他控制器是否不使用'index.php'工作? – Tpojka 2015-04-04 00:37:38

回答

0
在配置文件

改变它

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

这个

$config['index_page'] = ''; 

可能是做工精细

0

试试这可能有助于 的.htaccess文件将是:

<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'] = ''; 
0

打开config.php文件,并做以下内容替换

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

$config['index_page'] = "" 

只需更换

$config['uri_protocol'] ="AUTO" 

$config['uri_protocol'] = "REQUEST_URI" 

AND IN htaccess文件把下面的代码

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