In your .htaccess file, add the following code:
[sourcecode lang=”plain”]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php [L]
[/sourcecode]
Now create an index.php with the following script:
[php]
//FUNCTION FOR GETTING PAGE
function parseURI(){
//DEFAULT VALUE – SET TO LOGIN PAGE WHICH LOADS LOGIN.PHP
$retval = ‘login’;
$uri = $_SERVER[‘REQUEST_URI’];
if($uri !== ”){
$uri = explode(‘/’,$uri);
$length = count($uri);
if(isset($uri[$length – 1])){
$retval = $uri[$length – 1];
}
}
return $retval;
}
$currentUri = parseURI();
$file = $currentUri.".php";
//SEE IF FILE EXISTS
if(file_exists($currentUri.".php")){
//IF SO REQUIRE IT
require($currentUri.".php");
}else{
//OTHERWISE GO TO LOGIN
require(“login.php");
}
[/php]
Then create your url files in your project folder according to the pretty url. Example: localhost.com/testpage will attempt to find testpage.php and load it.
Recent Comments