我有codeigniter安裝在root/igniter文件夾中。CodeIgniter使用index.php
下根/點火器,我有以下.htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
頁打開,就像我會指望他們不使用「的index.php」。 因此,我的主頁位於http://example.com/igniter
,我的註冊頁面http://example.com/igniter/registration
也會打開。
然而,在我的登記表,提交按鈕,這是由CI控制器處理重定向到
http://example.com/igniter/index.php/registration
我已經確定,我的下應用/配置config.php文件有
$config['index_page'] = "";
這是我的登記控制器的樣子:
public function index()
{
$this->load->helper(array('form', 'url'));
$this->load->model('Registration_Model');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|callback_username_check|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[6]|max_length[12]|matches[passconf]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|callback_email_check');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('registration');
}
else
{
//input data into database here
$username = strtolower($_POST['username']);
$password = md5($_POST['password']);
$email = strtolower($_POST['email']);
$data = array
(
'username' => $username,
'password' => $password,
'email' => $email
);
$this->Registration_Model->addUser($data);
$this->load->view('registrationsuccess');
}
}
據我所見,我沒有明確要求控制器重定向到index.php/registration。
我沒有看到任何代碼會在這裏重定向。你確定這個表單的'action'沒有問題嗎?您可能想要顯示您的視圖代碼。 –