GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, April 17, 2011

Apache - Removing index.php

For removing index.php on url, type this code to an .htaccess file:
RewriteEngine On
RewriteRule ^[a-z]/* index.php


The process the script in the file of index.php

<?php

    // you can process the url use this one
    $q = $_SERVER['REQUEST_URI'];

    $queries = explode('/',$q);
   
    $page = $queries[1];

    if($page == 'css'){
        include "css/index.php";
    }else if($page == 'js'){
        include "js/index.php";
    }else if($page == 'hello'){
        include ("hello.php");
    }else{
        include "404.php";
    }
?>
Share/Bookmark

No comments:

Post a Comment