yamo1983
-
Posts
1 -
Joined
-
Last visited
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.
error 301 (too many redirects) on apache but works fine on IIS
in PHP Coding Help
Posted
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 :
#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.