[英]403 redirect error when submitting form Codeigniter
從本教程的第一部分運行表單時,出現403錯誤。
在研究並懷疑有mod_security限制后,我聯系了主機,他們告訴我我的內部重定向限制為10。錯誤如下。 他們說他們不支持開發,但是我懷疑由於我使用的是模板文件,因此這是由他們的環境引起的。
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://mywebsite.com/automation/codeigniter/form
如何找到重定向循環的原因,或者以其他方式解決我的403錯誤?
編輯:本教程中的URL使我轉到http://mywebsite.com/includes/codeigniter/index.php/form
表格...
<html>
<head>
<title>My Form</title>
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open(base_url('controllers/form.php')); ?>
<h5>Username</h5>
<input type="text" name="username" value="" size="50" />
<h5>Password</h5>
<input type="text" name="password" value="" size="50" />
<h5>Password Confirm</h5>
<input type="text" name="passconf" value="" size="50" />
<h5>Email Address</h5>
<input type="text" name="email" value="" size="50" />
<br><br>
<div><input type="submit" value="Submit" /></div>
</form>
<?php echo form_close() ?>
</body>
</html>
控制器...
<?php
class Form extends CI_Controller {
function index()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('myform');
}
else
{
$this->load->view('formsuccess');
}
}
}
?>
注意CodeIgniter用戶使用Front Controller 。
請查看您的重寫規則-這通常是重定向麻煩的情況。
檢查CI路由配置-有點奇怪:“ index.php / form”
您可以將CI LogLevel
設置為debug
以獲取回溯。
<?php echo form_open(); ?>
而不是放置“表單”,它應該是處理表單的控制器的URL。 由於您未發布控制器,因此我無法真正告訴您該放置什么。
<?php echo form_open(base_url('controller/method/arguments')); ?>
另外,如果您要使用表單幫助器,也可能會關閉表單。
<?php echo form_close() ?>
在根目錄中使用htaccess可以從網址中刪除index.php。
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
檢查Codeigniter目錄的根目錄的.htaccess是否不限制http POST,即
所有人都否認
如果沒有.htaccess,請檢查父目錄的繼承位置,因為htaccess規則是遞歸應用的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.