techrahul87
techrahul87

Reputation: 107

.htaccess url rewrite having issues

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

Answers (3)

Rijndael
Rijndael

Reputation: 3753

Try this:

RewriteRule ^/product/([0-9]+)/(.*).html$ ^/product.php?act=pro&cat=$1&category=$2 [NC,L]

Upvotes: 1

anubhava
anubhava

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

Orangepill
Orangepill

Reputation: 24645

Pattern that matches cat should have 0-9 in it

Upvotes: 0

Related Questions