请求超过了10内部重定向的限制

请求超过了10内部重定向的限制

本文介绍了htaccess的mod_rewrite的"请求超过了10内部重定向的限制,由于可能的配置错误。 "的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的.htaccess:

This is my .htaccess:

RewriteEngine ON

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

Options -Indexes

这是用在一个简单的框架和思路是像重定向请求:www.domain.com/subpage到index.php,它会调用子页面

It is used in a simple framework and the idea is to redirect request like: www.domain.com/subpage to index.php, which will call the subpage.

和我的index.php是:

And my index.php is:


    function __autoload( $className ) {
    $className = strtolower( $className );
    // Trying to find proper directory. For pages - all the predefined languages' directories must be present and checked!
    $file =  'pages_pl/' . $className . '.php';
    if( file_exists( $file ) ) { require( $file ); }
    else {
        $file =  'pages_en/' . $className . '.php';
        if( file_exists( $file ) ) { require( $file ); }
        else {
            $file = 'lib/' . $className . '.php';
            if( file_exists( $file ) ) { require( $file ); }
            else {
                $file = 'admin/' . $className . '.php';
                if( file_exists( $file ) ) { require( $file ); }
            }
        }
    }
}


// Get page class
$pageClass = Parameters::page();

$language = null;

if( $pageClass == '' )   //if the class was not given, one depending on language will be called
{
//take language from the cookie, if present and valid
    if(isset($_COOKIE['lang']) && Language::exists($_COOKIE['lang'])) {
        $page = new Language::$MAINPAGE[$_COOKIE['lang']];
    }
    else {
        $defaultMainPage = Language::getDefaultMainPage();
        $page = new $defaultMainPage();  //default main page
    }
}     //if the specific class exists, it will be loaded
else if( class_exists( $pageClass ) ) //this makes __autoload() run
{
    $class = new ReflectionClass( $pageClass );
    if( $class->isInstantiable() )
        $page = new $pageClass();  //instantiate proper page here
    else
        $page = new Error404();
}
else
    $page = new Error404();

$language = $page->getLanguage(); //get the page's language

?>
     //replaced triangle parentheses with round ones
    (head)
   ....
    (/head)
    (body)
        displayPart( 'top' );
        //print_r( $_SESSION );
            $page->displayContent();
            $page->displayPart( 'footer' );
        ?>
    (/body)
(/html)

和参数类:

And the Parameters class:

// This class decomposes URL address and returns: page, parameter1, parameter2 ...

class Parameters
{
    static private $isInitialized = false;
    static private $values;

    private function __construct() {
    }

    static private function init()
    {
        if( self::$isInitialized == true ) return;

        $url = substr( $_SERVER['REQUEST_URI'], strrpos( $_SERVER['REQUEST_URI'], '/' ) + 1 );


      if( strpos( $url, '?' ) )
      {
          $url = substr($url, 0, strrpos($url, '?'));
      }

        self::$values = explode( ',', $url );

        self::$isInitialized = true;
    }

    static public function page()
    {
        self::init();
        return self::$values[0];
    }

    static public function get( $index )
    {
        self::init();
        if( $index < count( self::$values ) ) return self::$values[$index];
            else return null;
    }
}

任何人都可以帮助吗?

推荐答案

确定。好像我的.htaccess的作品:

OK. Seems like I have .htaccess that works:

RewriteEngine ON

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

Options -Indexes

这篇关于htaccess的mod_rewrite的&QUOT;请求超过了10内部重定向的限制,由于可能的配置错误。 &QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:55