LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Rewrite rule with query string in the pattern string (https://www.linuxquestions.org/questions/linux-newbie-8/rewrite-rule-with-query-string-in-the-pattern-string-492266/)

basahkuyup 10-14-2006 01:02 AM

Rewrite rule with query string in the pattern string
 
I am new to linux and php. I am facing a problem in rewriterule that needs a solution to.

I would like to do a rewrite rule for the following:
from: products/8.html?start=2&pageno=2
to: productlist.php?catid=8&start=2&pageno=2

which is the second page of products with category 8. I have tried this in my .htaccess:

RewriteRule ^products/([0-9]+).html$ productlist.php?catid=$1 [L]

but it didn't work. It still gave me the first page. The values for 'start' and 'pageno' were not passed.

I tried putting QSA (Query String attach) as the following:

RewriteRule ^products/([0-9]+).html$ productlist.php?catid=$1 [L, QSA]

still did not work. Values for 'start' and 'pageno' still not passed.

Any input is welcome.

hobey 10-16-2006 07:55 AM

Works for me. (I tested it using exactly the same line in a .htaccess file and a script called productlist.php which would do nothing but output all the GET variables, and it showed all three of them with the correct values) The only thing is that there must be no space behind the comma in [L,QSA] (gave me a server error otherwise).

You might try to do the same. Just temporarily replace your productlist.php by something like 'print_r($_GET);' and see what variables it receives (add some <pre> tags to make output legible in the browser).

basahkuyup 10-17-2006 02:06 AM

Quote:

Originally Posted by hobey
Works for me. (I tested it using exactly the same line in a .htaccess file and a script called productlist.php which would do nothing but output all the GET variables, and it showed all three of them with the correct values) The only thing is that there must be no space behind the comma in [L,QSA] (gave me a server error otherwise).

Thanks hobey.

I removed the space and it works. Man, what a difference can a space makes.
Thanks again.


All times are GMT -5. The time now is 06:30 PM.