Reputation: 107
I am not able to customize a url using .htaccess. I applied all changes in .htaccess but this one stuck with me for long time.
I have a URL :
product.php?act=pro&cat=1&category=Nokia
I want to change it to:
product/1/Nokia.html
I used following rule:
RewriteRule ^product/?([a-zA-Z_]+)/([a-zA-Z_]+)\.html$ product.php?act=$1&cat=$2&category=$3 [QSA]
But not getting this one correct.
Upvotes: 1
Views: 68
Reputation: 3753
Try this:
RewriteRule ^/product/([0-9]+)/(.*).html$ ^/product.php?act=pro&cat=$1&category=$2 [NC,L]
Upvotes: 1
Reputation: 784898
You're capturing only 2 groups and using $1, $2, $3.
Change your code to this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^product/([^/]+)/([^.]+)\.html$ /product.php?act=pro&cat=$1&category=$2 [QSA,L,NC]
Upvotes: 4