PHP Apache Rewrite Rules and Variables -
i'm trying action value variables in url.
real url
index.php?action=ok&id=45&name=lg-optimus
friendly url
home/ok/1/lg-p88
this above friendly url show when redirect page this
header('location: /home/ok/' . $id . '/' . $name);
the page script contains code variables
$ok = isset($_get['ok']) ? $_get['ok'] : ""; if($ok=='ok'){ echo "<div class='popup'>"; echo "<strong>{$card-name}</strong> added!"; echo ""; echo "</div>"; }
but 'undefined index ok'.
the .htaccess file contains code
# turn rewrite engine on rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l # rewrite index.php rewriterule ^home index.php [nc,l] # rewrite card-name rewriterule ^home/([0-9]+)/([0-9a-za-z_-]+)$ index.php?action=$1&id=$2&name=$3 [qsa,l]
thanks help.
you setting get-variable action "ok", code presumes variable named "ok".
check in code should use:
$action = isset($_get['action']) ? $_get['action'] : ""; if($action=='ok'){
another thing, regular expression lacks "action" argument, try this:
^home/(.*)/([0-9]+)/([0-9a-za-z_-]+)$
Comments
Post a Comment