php - Hiding URL key parameters with .htaccess -
i've been searching on web , haven't yet found solution issue. i'm hoping shed light on situation.
i have index file set this:
<header></header> <div id="main"> <?php if(isset($_get["p"])) $p = $_get["p"]; else $p = "home"; if(file_exists("pages/{$p}.php")) include("pages/{$p}.php"); ?> </div>
which makes me load pages ?p=contact
href.
say display users profile. i'd create subfolder in "pages" folder, making relative path pages/users/profile.php
, href ?p=users/profile&uid=5
. leaves ugly url (as seo rating).
how rewrite url /users/profile/5
?
edit: i've tried following, resulting in http 500:
rewriterule ^([^/]*)/([^/]*)$ /?p=$1&uid=$2 [l]
edit: .htaccess file, located directly inside root folder: http://pastie.org/2268239
line 338 want achieve (currently comment).
simplest answer both situations add in .htaccess file
rewriteengine on rewritecond $1 !^(index\.php) rewriterule ^(.*)$ /index.php?$1 [l]
this redirect traffic on domain index.php file.
you determine in script using uri in $_server["request_uri"]
Comments
Post a Comment