In what scenarios is it preferable to use human-readable URLs over query parameters in PHP applications?

Using human-readable URLs is preferable over query parameters in scenarios where you want to improve the readability and SEO-friendliness of your website's URLs. Human-readable URLs are easier for users to understand and remember, and they can also improve the overall user experience. Additionally, human-readable URLs can help with search engine optimization by making it easier for search engines to crawl and index your website's pages.

// Example of using human-readable URLs in PHP

// .htaccess file to redirect all requests to index.php
// RewriteEngine on
// RewriteCond %{REQUEST_FILENAME} !-f
// RewriteCond %{REQUEST_FILENAME} !-d
// RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

// index.php file to handle the requests
$url = isset($_GET['url']) ? $_GET['url'] : '';
$segments = explode('/', $url);

// Example usage
// If the URL is example.com/products, $segments will be ['products']
// If the URL is example.com/products/123, $segments will be ['products', '123']