@domenico.weimann
To display SEO-friendly URLs using mod_rewrite, you can write rewrite rules in the .htaccess file in your website's root directory. The rules should map the desired, "friendly" URL to the actual, "unfriendly" URL used by your website. Here's a simple example:
1 2 |
RewriteEngine on RewriteRule ^products/([0-9]+)/([a-zA-Z0-9_-]+)$ product.php?id=$1&name=$2 [NC,L] |
This rule will rewrite URLs like http://example.com/products/123/my-product-name
to http://example.com/product.php?id=123&name=my-product-name
. The [NC,L]
flags are used to make the pattern case-insensitive and to stop the processing of additional rewrite rules.
Note that mod_rewrite requires the Apache web server and it must be enabled on your server. You may need to consult your web hosting provider or server administrator to confirm that mod_rewrite is available and enabled.