Reputation: 1411
I am facing problem to get variable from query string. I have used htaccess redirection for my page.
I have written following rule.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).htm$ category.php?uniqname=$1
RewriteRule ^([a-zA-Z0-9-/]+).htm/$ category.php?uniqname=$1
what this rule is doing if I type gold-plated-chain.htm
is browser that I am redirect to
category.php?uniqname=gold-plated-chain
Now I want to pass one varible so I am doing this way gold-plated-chain.htm?page=2
but I can't get page variable on category.php i am redirecting properly but without that page variable
Thank You in advance
Upvotes: 0
Views: 129
Reputation: 10898
You need to add a [QSA] flag to tell the rewrite engine to merge the query strings. It is always wise to add the [L] flag and specify a base. It's also wise to escape "." characters as this is interpreted as a wild card You can also combine these two rules. Hence:
RewriteEngine On
RewriteBase /
RewriteRule ^([\w-/]+)\.htm/?$ category.php?uniqname=$1 [L,QSA]
BTW, \w
is just a short-hand for a-zA-Z0-9
.
Upvotes: 1
Reputation: 4187
I /think/ what you're after is the QSA flag (see http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) which should append query strings.
Try adding [QSA] to the end of your RewriteRule lines.
Upvotes: 2
Reputation: 15846
you should remove ^ from the regexp. It means the start of the string.
Upvotes: 0