php - Problems with htaccess directories -
so, have .htaccess code (that don't know if it's best way write it):
options -indexes rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)$ index.php?p=$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)$ index.php?p=$1&$2= [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)$ index.php?p=$1&$2=$3 [l]
and @ index.php have code load content:
<div id="page-wrapper"> <? $p = ($_get['p'] ? $_get['p'] : 'home'); include_once('lib/'.$p.'.php') ?> </div>
when access www.web.com/home
, example, works fine loading files; when access www.web.com/articles/read/asd
, other files, instead of loading www.web.com/lib/pixel.png
, load www.web.com/articles/lib/pixel.png
.
what best way fix this?
so, solved problem: made code:
$p = ($_get['p'] ? $_get['p'] : 'home'); $directory_folder = explode('/', $_server['request_uri']); $directory_folder = $directory_folder[1]; $directory_folder = ($directory_folder == $p ? '' : $directory_folder);
so, if i'm accessing through www.web.com/
or www.web.com/test
, return directory of website want. had add /<? echo $directory_folder ?>/
src's , href's, worth it.
thanks mike rockett , guys helping me :)
Comments
Post a Comment