yamo1983 Posted November 8, 2015 Share Posted November 8, 2015 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 1RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.+)$ index.php?url=$1 [L]</IfModule>would be very grateful if someone could hep me please. Quote Link to comment https://forums.phpfreaks.com/topic/299365-error-301-too-many-redirects-on-apache-but-works-fine-on-iis/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.