Thursday, 15 August 2013

php - Dynamic URL rewriting -



php - Dynamic URL rewriting -

i working on e-commerce website , trying create url better. enabled apache configuration, created .htaccess file, url still same. not able figure out going wrong.

if url this: http://www.public_html/products.php?scatid=72

and want this: http://www.public_html.com/products/scatid/72

i have php file as:

if($cntrec_prod > 0){ $cnt = 0; mysql_data_seek($srsprod_mst,0); while($srowsprod_mst=mysql_fetch_assoc($srsprod_mst)){ $db_catone_id = $srowsprod_mst['prodcatm_id']; $db_catone_name = $srowsprod_mst['prodcatm_name']; $db_cattwo_id = $srowsprod_mst['prodscatm_id']; $db_cattwo_name = $srowsprod_mst['prodscatm_name']; $db_dys_lft = $srowsprod_mst['dyslft']; $smlimg_lst = $srowsprod_mst['prodimgd_simg']; $avl_prd = $srowsprod_mst['avlprd']; //$lnkname = "products.php?scatid=$db_cattwo_id"; $ary_imgnm = explode('--',$smlimg_lst); $img_cnts = ''; $img_frstcnts =''; $imginc = 0; $scatid_lst .= "--".$db_cattwo_id.'-'.$db_dys_lft; for($inc=0;$inc<count($ary_imgnm);$inc++){ $scat_imgnm = $ary_imgnm[$inc]; $scat_imgpth = $u_sml_upldpth.$scat_imgnm; if(($scat_imgnm != '') && file_exists($scat_imgpth)){ $imginc ++; if($inc == 0){ $img_frstcnts = "<a href='products.php?scatid=$db_cattwo_id' class='catimg'><img src='$scat_imgpth' width='300' height='350' border='0' alt=''></a>"; } $img_cnts = "<a href='products.php?scatid=$db_cattwo_id'><img src='$scat_imgpth' width='300' height='350' /></a>"; } else{ $img_frstcnts = "<a href='products.php?scatid=$db_cattwo_id' class='catimg'><img src='images/noimage.jpg' width='300' height='350' border='0' alt=''></a>"; } } $dsp_name = $db_cattwo_name; ?>

my .htaccess files contains next code:

rewriteengine on rewritebase /public_html/ rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php rewriterule products/scatid/(.*)/ products.php?scatid=$1 [l,qsa] rewriterule products/scatid/(.*) products.php?scatid=$1 [l,qsa]`

rewriteengine on rewritebase /

#add these rewritecond %{request_filename} !-f rewritecond %{request_filename} -d rewritecond %{request_uri} !/$ rewriterule (.*) /$1/ [r,l] rewritecond %{http_host} !^example.nl$ [nc] rewriterule ^(.*)$ http://example.nl/$1 [l,r=301] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l]

php apache .htaccess mod-rewrite

No comments:

Post a Comment