Reputation: 7906
i am using url rewriting like
RewriteRule ^mobiles/(.*)$ /mobile_rating.php?alias=$1 [L,B]
which works well for me like
/mobiles/nokia70 /mobile_rating.php?alias=nokia70
i need a small change like
/mobiles/nokia70 /mobile_rating.php?alias=nokia70&product=mobiles
i mean to say like the mobiles in url must be changed to product=mobiles ..how do i do it..any tips
Upvotes: 0
Views: 51
Reputation: 72510
If you mean that the product variable is determined from the first part of the URL, this will do it:
RewriteRule ^(.*)/(.*)$ /mobile_rating.php?alias=$2&product=$1 [L,B]
However, I would change the character match from .*
to something less generic. The above will rewrite /mobiles/nokia70/abc
to /mobile_rating.php?alias=abc&product=mobiles/nokia70
.
[^/]+
will match a string that doesn't contain the forward slash, or if you're always using a strict set of letters/numbers, try [a-z0-9-]+
which will match any lowercase letter, digit or the hyphen.
Upvotes: 1