0

I'm creating a PHP page that holds a collection of items displayed to the user similar to an E-commerce site. When the user clicks on an item I would like them to be taken to a more detailed page for that particular item. I have seen the GET request method to do this but the URL looks a bit messy:

e.g. website.com/product.php?id=23

What I'm aiming for is something like this:

website.com/product/<name-of-item-or-page> 

Entering that URL would then navigate to the page referenced. How is this done? I know I'm looking to complete this using POST requests, but for this particular problem I wasn't even sure how to Google this. If possible can this be done without external libraries?

Also, what keywords would I Google in the future to narrow down my specific problem? Tried my best with variations of the title.

2 Answers2

1

The solution is not converting get to post request.

To make yours urls seo friendly edit your .htaccess file.

Read this article https://www.danielmorell.com/guides/htaccess-seo/user-friendly-urls/make-your-urls-seo-friendly

0

You Can use urlencode() for this:-

<?php
include("dbconn.php");

$sql ="SELECT * FROM `table`";
$exe = mysqli_query($conn,$sql);

$table="";
while($arr=mysqli_fetch_array($exe)){
    $word = $arr['word'];
echo $table.="<a href='detail.php?title=".urlencode($word)."';>Title of Heading</a>";
}
KUMAR
  • 1,993
  • 2
  • 9
  • 26