Это мой .htaccess:
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
Options -Indexes
Он используется в простом фреймворке, и идея состоит в том, чтобы перенаправить запрос, например: www.domain.com/subpage, на index.php, который будет вызывать подстраницу.
И мой index.php:
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)
И класс параметров:
</p>
<pre><code>// 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;
}
}
Может кто-нибудь помочь, пожалуйста?