php - .htaccess Clean Url with multiple parameters -


i'm newbie in php , htaccess, , first post. have problem in url, wanted make clean. way, url have

http://www.example.com/index.php?page=home&lesson=1.1  

how can change

http://www.example.com/home/1.1/ 

and here index.php code

<?php     include("page_check.php"); // program check requested page.      include($page); // home.php, login.php , etc     include("templates/layout.php"); //the template, contains html tags... ?> 

page_check.php code...

<?php     session_start();     $page = $_get['page'];     $array_page=array('home','create_group','group','try_it_out','logout');     $page_no_session=array('login','register','email_confirmation');     $len;     if (!empty($_session['login_state'])){         $len = count($page_no_session);         for($i = 0; $i < $len; $i++){             if ($page_no_session[$i] == $page){                 $page = "home";             }         }         if(empty($page)){             $page = "home";         }     }     else{         if(empty($page) , empty($_session['login_state'])){             $page = "login";         }         else{             $len = count($array_page);             for($i = 0;$i < $len;$i++){                 if ($array_page[$i] == $page){                 $page = "login";                 }             }         }     }         $page = "$page.php"; //this i'm telling, home.php, login.php , etc.. defends upon requested php file ?> 

by way guys. want url nice , clean , want ask advice other things can make website more secure. hope me.

you can use code in document_root/.htaccess file:

rewriteengine on rewritebase /  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/?$ index.php?page=$1&lesson=$2 [l,qsa]  

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -