How can PHP routing be implemented to display user-friendly URLs for category pages in a webshop system?

To implement user-friendly URLs for category pages in a webshop system using PHP routing, you can use a combination of .htaccess rules and PHP code to map the friendly URLs to the corresponding category pages. This involves rewriting the URLs to pass the category information as a parameter to your PHP script, which then uses this information to display the appropriate category page.

// .htaccess rules to rewrite the URLs
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9-]+)$ category.php?category=$1

// PHP code in category.php to display the category page based on the parameter
<?php
$category = $_GET['category'];

// Query the database or any other method to fetch and display the category page based on the $category parameter
?>