php - .htaccess redirect from path to file -


i want set custom template system website i'm working on, want redirect requests single file. if user visits url http://www.mywebsite.de/products/software/ want redirect request file index.php, following:

$look_at = $_get['first_level']; //for example: products if($look_at == 'products') {     $look_at = $_get['second_level']; //here: software     if($look_at == 'software') {         //show software specific stuff     } else if ($look_at == 'hardware') {         //show hardware specicif stuff     } else {         //show error message     } } else {     //show error message } 

then, use include to, include, other html files index.php depending on being requested.

in end, request http://www.mywebsite.de/products/software/ supposed same http://www.mywebsite.de/index.php?first_level=products&second_level=software

rewriteengine on  redirectmatch 403 /\..*$ # if directory or file exists, use them directly rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d # otherwise, send request index.php file rewriterule . index.php 

next in php example:

$uri = $_server['request_uri'];  if (($qpos=(strpos($uri,'/?')))!==false)   $uri=substr($uri,0,++$qpos); elseif (($qpos=(strpos($uri,'?')))!==false)   $uri=substr($uri,0,++$qpos);  $uri = (preg_replace('/^\/|\/$/', '',$uri)); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -