Question

I get a 403 error when running the form from the first part of this tutorial.

I contacted my host after researching and suspecting a mod_security limitation, they tell me I'm hitting an internal redirect limit of 10. The error is below. They say they won't support development but I suspect that since I'm using the template files that it's their environment causing the problem.

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 

How can I find the cause of the redirect loop, or otherwise fix my 403 error?

Edit: the URL from the tutorial has me going to http://mywebsite.com/includes/codeigniter/index.php/form

The 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>

The controller...

    <?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');
        }
    }
}
?>

Note CodeIgniter user a Front Controller.

Was it helpful?

Solution 3

Check that .htaccess of root of Codeigniter dir does not restrict http POST i.e.

deny from all

If there is no .htaccess, check in parent dir's where this limit might be inherited, since htaccess rules are applied recursively.

OTHER TIPS

Please take a look at your rewrite rules - that's often a case of redirection trouble.

Check the CI routing configuration - a bit strange: "index.php/form"

You might set the CI LogLevel to debug to get the backtrace.

<?php echo form_open(); ?>

Instead of putting 'form' this should be the URL to the controller that will process the form. Since you did not post your controller I can't really tell you what to put there.

<?php echo form_open(base_url('controller/method/arguments')); ?>

Also if you are going to use the form helper.. might as well close the form with it as well.

<?php echo form_close() ?>

Use htaccess in the root to remove index.php from the url.. something like this would work..

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top