전자 상거래 웹 사이트에서 작업 중이며 URL을 개선하려고합니다. Apache 구성을 활성화 한 다음 .htaccess 파일을 만들었지 만 내 URL은 여전히 동일합니다. 나는 내가 어디로 잘못 가고 있는지 알 수 없다.동적 URL 다시 쓰기
내 URL이 같은 경우 : http://www.public_html/products.php?scatid=72
나는 그것을 같이 할이 : http://www.public_html.com/products/scatid/72
내 PHP 파일이이 같이 내 .htaccess 파일이 포함되어
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;
?>
다음 코드 :
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]`
'\ $'당신이'$ '기호 대신'/을 탈출하는 잘못된 : 당신은 또한 다음과 같이 마지막 재 작성 규칙을 변경해야합니까? $' –
.htaccess 모든 것이 최선의 방법은 아닙니다. ** 라우터 **를 사용하거나 자신을 프로그래밍하십시오. – Xatenev
변경 사항을 시도해 보니 여전히 URL이 동일해야하는 경향이 있습니다. 제안 주셔서 감사합니다 @ Rahil ny 다른 제안도 hlpful 될 것입니다 – Priyanka