0

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

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

you should remove ^ from the regexp. It means the start of the string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.