1

I got the difficult when rewrite rules with multiple parameter,to modify a URL to SEO-friendly.

My URL:

http://domain/cat.php?alias=canon&sort=price&page=3

I want to have a rewrite rule so that the following:

http://domain/c/canon?sort=price&page=3

Heres my current rule:

RewriteEngine On
RewriteRule ^c/([a-z,0-9-]+)$ cat.php?alias=$1 [L]
RewriteRule ^c/([a-z,0-9-]+)?sort=([a-z]+)$ cat.php?alias=$1&sort=$2 [QSA]
RewriteRule ^c/([a-z,0-9-]+)?sort=([a-z]+)&page=([0-9]+)$ cat.php?alias=$1&sort=$2&page=$3 [QSA]

I try to get the params but it doesn't work. Anyone have any ideas on which rewrite rules to use?

Thank you! --hatxi

1 Answer 1

1
RewriteRule ^c/([a-z,0-9-]+) cat.php?alias=$1 [L,QSA]

Should be enough. The QSA flag will take care of passing the sort and page parameters.

Your rules don't work because of the [L] flag on the first one, it just discards the rest because it always matches first.

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

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.