2015-04-03 81 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]