Reputation: 127
My current web root directory has:
/product-a.php
/product-b.php
How to I rewrite it so that:
it auto detects and displays all URL ending with /product-a.php on my site to become /products/product-a
when clicking onto these links /products/product-a it send back requests as /product-a.php
Thanks for your help!
Andy
Upvotes: 2
Views: 107
Reputation: 785226
nable mod_rewrite
and .htaccess
through httpd.conf
and then put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteRule ^products/([^/]+)/?$ /$1.php [L,NC]
Upvotes: 1