i trying hide .php extension , rewriting url string trailing slashes. file extension hiding working fine url string not.
from:
http://www.example.com/abc.php?id1=1&id2=2
to:
http://www.example.com/abc/id1/1/id2/2
following .htaccess
rewriteengine on options -multiviews rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^\.]+)$ $1.php [nc,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{query_string} (.*) rewriterule ^(.*)\/([0-9]+)$ $1.php?id=$2&%1 [l]
first, check %{the_request}
variable. redirect if satisfies match conditions.
rewritecond %{the_request} ^get\ /abc\.php\?(id1)=(\d+)&(id2)=(\d+) [nc] rewriterule ^ /abc/%1/%2/%3/%4? [r=301,l]
next, internally rewrite friendly-url.
rewriterule ^abc/(id1)/(\d+)/(id2)/(\d+)$ /abc.php?$1=$2&$3=$4 [nc,l]
Comments
Post a Comment