We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40092
    • 265 Posts
    Well, having had a hard time of converting my custom rewrites to Revo, i'm now again stuck at something that doesn't make sense.(to me, at least).

    I'm having this rule in .htaccess:
    RewriteRule ^path/(.*)$ resources/path.html?variable=$1 [L]

    Why i have to use resources in front of it, is , i think, because path.html is an alias of a document that is in a folder called resources. If anyone knows how to bypass this, please share:-) I now got working that the page actually redirects to path/variable.html, but when i try and get the value of $_GET['variable'] it remains empty.

    Anyone knows whta this might be?

    This question has been answered by sottwell. See the first response.

    [ed. note: thapriest86 last edited this post 13 years, 6 months ago.]
      • 40092
      • 265 Posts
      Well, seems to be multiple issues.

      First, calling the $_GET['var'] from my snippets returns just plain empty.
      Secondly, it adds .html to the var (the call works when calling from the main template wich is calling the snippets.)

      So when having:
      RewriteRule ^path/(.*)$ resources/path.html?variable=$1 [L]


      should translate in my browser to:
      http://localhost/abcrevo/path/var.html
        • 3749
        • 24,544 Posts
          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
          • 40092
          • 265 Posts
          Thanks Bob, but no, unfortunately not.

          It seems to be that i myself cannot find my way with the new look at doing things in revo, yet.
          Creating a new and working site on Revolution is a breeze, migrating from evolution to revolution is a whole different cup of tea.

          (for the record, the migrated one is my main website and quite large, the smaller ones i already handled).

          I'll be nose deep in that book of yours again. smiley [ed. note: thapriest86 last edited this post 13 years, 7 months ago.]
            • 3749
            • 24,544 Posts
            How are the links with the $_GET params specified?
              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
              • 40092
              • 265 Posts
              You mean how i am calling them? that would be http://localhost/abcrevo/path/var.html

              What i am actually calling is a document in a Container, with an alias named 'path'.
              Out of the box that would make the URL something like http://localhost/abcrevo/Container/path.html when no rewrite at all it would be somehing like index.php?q=resources&idontknowwichvariable=documentsname ?
                • 3749
                • 24,544 Posts
                I thought you were adding your own $_GET params to the URL. Why do you want to get the ones MODX passes when FURLs are off (and why do you want FURLs off)? I can't think if anything that would get you that wouldn't be easier to do another way.

                Normally, links to pages on a MODX site look like this, using the Resource ID of the page you want to link to (in parentheses in the Resources tree):

                <a href="[[~12]]">Some Page</a>


                That way MODX handles the details for you and you can change the pagetitle and/or alias of the document and the link will still work fine.

                Also, why not use the Friendly URL rewrite rules in the ht.access file that comes with MODX (by renaming it to .htaccess)? The only thing I've ever had to adjust is the RewriteBase (and I've only had to do that on localhost installs with XAMPP).

                  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
                • discuss.answer
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  One nice feature of Revo is that you can drag-and-drop the target resource from the Resource Tree into most editing fields to get the MODx link tag automatically inserted.

                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 40092
                    • 265 Posts
                    Quote from: BobRay at Feb 27, 2013, 09:32 PM
                    I thought you were adding your own $_GET params to the URL. Why do you want to get the ones MODX passes when FURLs are off (and why do you want FURLs off)? I can't think if anything that would get you that

                    Oops, i guess i did not explain it all too well, it was late and had a sick child. >_<

                    I have extracted the url as it would be when using:

                    $qs = $class->getCurrentQueryString($_SERVER['QUERY_STRING']);
                    $query_string = "index.php?".$qs;
                    
                    //The Function
                    
                    function getCurrentQueryString($qs){
                    		$queryString = strip_tags($queryString);
                    		$queryString = strtolower($qs);
                    	return $queryString;
                    	}
                    //wich returns on print :
                    q=mydocument.html&variable=myvariable&variable2=0&myvariable3=0&myvariable4=0
                    


                    And what i want to be able to is bend that url to a pretty one like myurl.com/mydocument/myvariable.html
                    I tried with this, but no such luck:
                    RewriteRule ^mydocument/(.*)$ resources/mydocument.html?variable=$1 [L]


                    These are the FURL settings i use:


                    @sottwell
                    I did not know that, that is a nifty feature. Thanks:-)

                    UPDATE:

                    I think, the rewrite is now working with the following code:
                    # The Friendly URLs part
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    
                    RewriteRule ^path/(.*)$ path.html?variable=$1 [L]
                    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                    


                    The crazy part is, the $_GET array is still empty on variable like:
                    Array ( [q] => path.html [variable] => )


                    But when extracting the url QUERY_STRING, it looks like this:
                    q=index.php&q=path.html&variable=myvariable.html
                    


                    So, the $_GET array should NOT be empty on variable AND secondly i don't need the .html addition on the var but i guess that has something to do with the content type settings? [ed. note: thapriest86 last edited this post 13 years, 7 months ago.]
                      • 40092
                      • 265 Posts
                      Well, right now i'm pulling my hair out. Lost the .html addition but stil my $_GET var remains empty.

                      Calling QUERY_STRING it shows that my $_GET var is there and filled, calling print_r ($_GET); shows the var is there but not filled.