Url friendly htaccess PHP

57 Views Asked by At

I have a product page and need the user to access it , but with the product name.

How it works: localhost/product?id=2

I want it that way: localhost/computer

My code .htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^confirmation/?$ confirmation.php [NC,L]
   RewriteRule ^/product/([^/]+)/$ product.php?id=$1 [QSA,L]
</IfModule>

Is not working, where I'm going wrong ?

1

There are 1 best solutions below

0
Amit Verma On BEST ANSWER
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^confirmation/?$ confirmation.php [NC,L]
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^/?([^/]+)/?$ product.php?id=$1 [QSA,NC,L]
</IfModule>