We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37801
    • 11 Posts
    I do not know a lot about htaccess and have been trying to figure something out. I have a dynamic page that pulls info from custom database tables.

    The original url was www.domain.com/index.php?id=60&code=254&cat=9

    With friendly urls turned on, it now goes to www.domain.com/example, but I need it to go to www.domain.com/example?code=254&cat=9

    I would ultimately like it to pull the URL from a table, but I know that's asking a lot, so the above will do the trick.

    I thought having [QSA] in the htaccess line directs it to keep the parameters, but it does not.

    If anyone has any insight into this, I would appreciate it.
      • 40045
      • 534 Posts
      are you using the standard .htaccess file shipped with modx? If not, have a look at how the URL rewriting is done there, I have no problem at all with request like in your example.
        • 37801
        • 11 Posts
        Quote from: exside at Sep 24, 2014, 04:54 AM
        are you using the standard .htaccess file shipped with modx? If not, have a look at how the URL rewriting is done there, I have no problem at all with request like in your example.

        Sorry I was tired - I meant to put in here that yes, I am using the htaccess file that was shipped. I have tried modifying it in several different ways also. I can't understand why the default way doesn't work.

        # The Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]


        Again, I know very little about htaccess, but have tried to even split the parameters into folder names because I would be able to handle that way also. But that is the first time ever i have attempted to write a rule:

        RewriteRule ^example/([^/]+)/(.*)/ index.php?q=$1&code=$2&cat=$3 [L,QSA]


        (and I have tried all different types of regexp in there)

        I don't even know if something like that would work or not though as the 2 extra parameters are only on 2 pages of the site.

        Was thinking that should take it to example/254/9/


        With the default htaccess, should the parameters be visible in the url?
        Is there anything in ModX that would prevent the parameters from passing (freeze uri for example)?
        I have no extensions (by creating a new blank content type) - would that cause issues? [ed. note: itcassy last edited this post 12 years ago.]
          • 3749
          • 24,544 Posts
          It depends on how you are creating the URL.

          Usually, it's done with $modx->makeUrl(), with the ID of the Resource in the first argument and the parameters in the third argument:


          $url = $modx->makeUrl(25, '', array('param1' => 'value1', 'param2' => 'value2'));


          You can also do it with a link tag (MODX Revolution format):

          [[~42? &scheme=`full` &parameter1=`value1` &parameter2=`value2`]]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting