Web Analytics Made Easy -
StatCounter Need help with .htaccess with query string - CodingForum

Announcement

Collapse
No announcement yet.

Need help with .htaccess with query string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with .htaccess with query string

    I have this in my .htaccess:

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

    I have a page productlist.php that lists all products for a particular category (catid). The rewriterule works fine if I have only 1 page of products. Example:

    products/8.html will be rewritten to productlist.php?catid=8

    The problem is when I have to go to second page of a particular product category, it will keep showing the first page. The link to second page is the following:

    products/8.html?start=2&pageno=2

    I expect the rewriterule will rewrite it to

    productlist.php?catid=8&start=2&pageno=2

    but it didn't happen.

    Anyone have any ideas?

  • #2
    Have a look at Search Engine-Friendly URLs for several methods with which you can incorporate multiple variables into your URLs. Alternatively, you could have pages with the category name in the page, something like this:

    Code:
    RewriteRule ^OneCategory([0-9]+)\.php /OneCategory.php?page=$1 [L]
    That way, the page number is the only variable in the URL.
    Music Around The World - Collecting tips, trade and want lists, album reviews, & more

    Comment


    • #3
      Thanks vinyl-junkie. I went to the site but could not find the help that I need.
      Anyway I have found a way to this. I add QSA in the rewriterule as the following:

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

      and it works.

      Comment


      • #4
        Originally posted by basahkuyup View Post
        RewriteRule ^products/([0-9]+).html$ productlist.php?catid=$1 [L,QSA]
        Excellent! This is something that I wasn't aware of. Thanks!
        Music Around The World - Collecting tips, trade and want lists, album reviews, & more

        Comment

        Working...
        X