Jump to content

error 301 (too many redirects) on apache but works fine on IIS


yamo1983

Recommended Posts

Hello .
I have a project written in PHP based on MVC. 
The problem is I get a 301 error on apache but not on windows servers.
I converted web.config to htaccess file using an online tool.
now the details of the problem : 
the url is like : www.abc.com?cid=0 in which cid is id of a root of a explorer tree structure. now each time this url is called this cid should change to return the childs of that node.
The code in the constructure of the controller and where the loop happens :

 

function __construct() {

 
parent::__construct ();
Auth::handleLogin ();
 
if (! (isset ( $_GET ['cid'] ) && strlen ( $_GET ['cid'] ) > 0)) {
header ( 'location: ' . URL . "newscategories?cid=0" );
}

}

 

The actual method in controller to handle request : 

 

function index() {
if (Auth::handleLogin () && Auth::HasPermission ( PER_MNG_NEWS_GROUP )) {
// -------------
$cid = 0;
if (isset ( $_GET ['cid'] ) && strlen ( $_GET ['cid'] ) > 0) {
$cid = $_GET ['cid'];
}
$this->view->editid = '';
if (isset ( $_GET ['e'] )) {
$this->view->editid = $_GET ['e'];
}
// ---------------
$tknid = self::get_token_id ();
$tknvl = self::get_token ();
$_SESSION ['TOKENEXPIRETIME'] = time () + TokenDeadLine;
 
$this->view->cat_list = $this->model->getcats ( $cid );
$this->view->cat_path = $this->model->getcatpath ( $cid );
 
if (sizeof ( $this->view->cat_path ) == 0)
header ( 'location: ' . URL . "newscategories?cid=0" );
$this->view->cid = $cid;
$this->view->tokenid = $tknid;
$this->view->tokenvalue = $tknvl;
$this->view->render ( 'news/categories' );
}

 

 

I should mention this works fine on IIS and the content of htaccess is :
 

Hide   Copy Code

#SECURITY
 
<IfModule mod_rewrite.c>
RewriteEngine On
 
#REWRITE RULES
#RULE IMPORTED RULE 1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [L]
</IfModule>

would be very grateful if someone could hep me please.

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.