We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15888
    • 7 Posts
    Hi there.

    I’m wanting to port over a shopping cart system I wrote, into modx.

    For the front end I have one page which does all of the product listings (/products/index.php). All products URLs are rewritten in APACHE to this single content ’grabber’. ie /products/category1/subcategory/product-name.php is rewritten to /products/index.php

    This product grabber script reads the original URL and builds the page from the database of products and categories.

    My question is, what is the preferred method to do this in modx? Initially I was thinking of putting the same apache rewrite into the .htaccess file and have it rewrite to a page that contains the product display snippet. Is there a better way?

    Regards,
    Kim Richardson
      • 25663 MODX Staff
      • 12,272 Posts
      That would seem to work to me.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 15888
        • 7 Posts
        I’ve got a wierd problem I’ve never come across before.

        I’m using the following ReWrite Directive as below in my /.htaccess

        RewriteEngine On
        RewriteBase /
        RewriteRule ^shop/.*$ /shop.html [L,QSA]

        Where /shop.html contains the snippet to parse the url.

        Now I’m getting 400 Bad Requests in IE.

        Any ideas?

        Regards,
        Kim
          • 22303 MODX Staff
          • 10,725 Posts
          Are you using friendly URL’s? If so, that’s not going to work with the existing rewrite rules. By shop.html contains the snippet, I assume you mean shop.html is the FURL alias of a MODx document?
            • 15888
            • 7 Posts
            Yes I’m using Friendly URLs.

            I changed the rewrite to

            RewriteRule ^shop/.*$ /index.php?id=15

            where 15 is the page id of the shop content grabber and all is working fine.
              • 33372
              • 1,611 Posts
              I think the first method wasn’t working for you because the L at the end of your rule means it will be the last one executed. So that means that it can never get to the MODx rewrite rule below it to resolve shop.html to the correct document within MODx. Removing the L there would probably do the trick.
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options