1

my .htaccess file works fine with the following url

http://www.mywebsite.com/product/category/Girls-Clothes

.htaccess file:

RewriteEngine On

RewriteRule ^product/category/([a-zA-Z0-9-/]+)$ /product/category/category.php?cid=$1
RewriteRule ^product/category/([a-zA-Z0-9-/]+)/$ /product/category/category.php?cid=$1

but when i use page number along with friendly url, it would not work

http://www.mywebsite.com/product/category/Girls-Clothes?pno=2

i have tow variables cid and pno, CID is mentioned in .htaccess but when i wtore "pno" its gives me sql error.

RewriteRule ^uk/category/([a-zA-Z0-9-/]+)$ /uk/category/category.php?cid=$1?pno=$1
RewriteRule ^uk/category/([a-zA-Z0-9-/]+)/$ /uk/category/category.php?cid=$1?pno=$1

please let me know where i am doing wrong

1
  • 1
    You ought to be using an ampersand (&) between the querystring parameters. Like: /uk/category/category.php?cid=$1&pno=$1 Commented Jul 29, 2012 at 0:56

1 Answer 1

2

With your current attempt, you are replacing the value of pno with the same value in cid, "Girls-Clothes", and I suspect that isn't what you want.

Just use the QSA flag to append the existing query string onto the request, so the pno= is passed through the rewrite along with the cid parameter you added.

RewriteRule ^uk/category/([a-zA-Z0-9-]+)/?$ /uk/category/category.php?cid=$1 [L,QSA]

Notice also I reduced it to one line by appending /? and removing / from the [] to make the trailing slash optional.

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

2 Comments

is my anchor link is corrent...(mywebsite.com/product/category/Girls-Clothes&pno=1)...but it gives me error object not found..
@ReelMark The query string should start with ?pno= not &pno=. The way you have it, the & would cause it not to match your rewrite rule pattern and you'd get a 404.

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.