How do I retrieve the abc123 part of the URL below with .htaccess please?

I need to use the abc123 part to create a query. Ordinarily, I know this can be achieved with:

and getting the abc123 part with $_GET like this:

$product_key = $_GET['key'];

but I would prefer the htaccess method, which I need help with.


put and play with this rule in your .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?product/(.*?)/?$ /index.php?key=$1 [L]

Leave a Reply

Your email address will not be published. Required fields are marked *