#Hello: in my localhost I have successfully rewrite this link news-details.php?nid=13 as news/13 using the following code:
RewriteEngine on
RewriteCond %{QUERY_STRING} !^nid=
RewriteRule ^news/(.+) news-details?nid=$1
For all the remaining non-pretty links both news-details.php?nid=idnum and news/idnum works perfectly without any error now but what is missing is how to ignore the non-pretty url and display the pretty url on the browser
I have tried 5 different htaccess code to redirect the non-pretty to the pretty url but no one succeeded
I have also tried changing the php code from:
From this: <.a href=ânews-details.php?nid=<?php echo htmlentities($row['pid')?>â class=âbtn btn-primaryâ> Read More â</a.>)
To this: <.a href=ânews-details/<?php echo htmlentities($row['pid')?>â class=âbtn btn-primaryâ> Read More â</a.>)
Then the nid in ($_GET[ânidâ]) bellow becomes undefined index
<?php $pid=intval($_GET['nid']); $query=mysqli_query($con,"select tblposts.PostTitle as posttitle,tblposts.PostImage,tblcategory.CategoryName as category,tblcategory.id as cid,tblsubcategory.Subcategory as subcategory,tblposts.PostDetails as postdetails,tblposts.PostingDate as postingdate,tblposts.PostUrl as url from tblposts left join tblcategory on tblcategory.id=tblposts.CategoryId left join tblsubcategory on tblsubcategory.SubCategoryId=tblposts.SubCategoryId where tblposts.id='$pid'"); while ($row=mysqli_fetch_array($query)) { ?>The site got suspended so I use localhost, pls I need help To make this work using either php code or a simple htaccess code. Thank you