We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25357
    • 92 Posts
    .. Or maybe I’m missing something basic and it’s not modX at all. I had a similar problem last month but this is different. This is my 10th modX install but first on IIS7 (don’t run away . . it’s good news mostly . . . )

    Revo 2.0.8 on IIS7 as mentioned, using MS Rewrites for extensionless FURLS, for the most part, it’s working great. Until I try to post a form.

    If I try to post to /resource, of course the rewrite rewrites to /index.php?q=resource, poof goes my post data.

    My "sorta solution" attempt was to post directly to index.php?q=resource, but something in modX is redirecting again from that URL to the alias and poof goes my post data. That is, I should have seen index.php?q=resource in the address bar and it isn’t, it’s /resource, and I can see it happen in Live Headers. It posts to /resource, then I get a 302 followed by a location header sending it back to /resource post data-less.

    What am I missing?
      • 3749
      • 24,544 Posts
      Are you posting with a link tag?

      <form action="[[~##]" method="post>


      Where ## is the ID of the resource you’re posting to. Or, if it’s posting to itself:

      <form action="[[~[[*id]]]]]" method="post">
        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
        • 25357
        • 92 Posts
        Thanks Bob, right, this is where I started:

        <form action="[[~1234]]" method="post">

        which gives me resource in the output, but when it hits the rewrite rule does

        index.php?q=resource

        I then changed the request URL (form url) to

        <form action="index.php?q=[[~1234]]" method="post">

        I tested both of these by temporarily changing the rewrite rule to

        rewrite-test.php?q={R:0} (this is IIS, mind you)

        where rewrite-test.php just prints out all get and post variables. Everything is there, intact, both in get and post.

        It’s only after I pass it to modx that it redirects - and it does redirect, as posted above, to the "friendly" URL.

        Fresh Monday, gotta solve this somehow, will be working on it this A.M.


          • 25357
          • 92 Posts
          This is the output from Live Headers that describes the problem, actual names globally replaced.

          Note: POST DATA -> rewrite rule rewrites properly ->
          MODx accepts the input and redirects resulting in the second GET. Poof goes my post data.

          http://example.com/resource

          POST /resource HTTP/1.1
          Host: example.com
          User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
          Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
          Accept-Language: en-us,en;q=0.5
          Accept-Encoding: gzip,deflate
          Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
          Keep-Alive: 115
          Connection: keep-alive
          Referer: http://example.com/resource/
          Cookie: __switchTo5x=96; __unam=b8600ea-12efd815405-13919288-9; PHPSESSID=qkv1tu04oemhirkktrqaaetve4; ys-modx-resource-tree=a%3As%253A/root%5Es%253A/root/web_0/web_1%5Es%253A/root/web_0/web_8%5Es%253A/root/web_0/web_45%5Es%253A/root/web_0; ys-modx-leftbar-state=o%3AactiveTab%3Dn%253A1; ys-modx-element-tree=a%3As%253A/root%5Es%253A/root/n_type_chunk%5Es%253A/root/n_type_chunk/n_chunk_category_7%5Es%253A/root/n_type_snippet%5Es%253A/root/n_type_snippet/n_snippet_category_4
          Cache-Control: max-age=0
          Content-Type: application/x-www-form-urlencoded // here is the posted data
          Content-Length: 121
          your-name=fdgdsfg&form-field-1=dsfgd%40fdsgdsfg&form-field-2=sdfgdsfg&comments=dsfgg+dsfg+dsfg+dsf+g&submitButton=Form+Test%21
          HTTP/1.1 302 Moved Temporarily // WHERE DOES THIS COME FROM?
          Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
          Pragma: no-cache
          Content-Type: text/html; charset=UTF-8
          Expires: Thu, 19 Nov 1981 08:52:00 GMT
          Location: http://example.com/resource/
          Server: Microsoft-IIS/7.5
          X-Powered-By: PHP/5.3.5, ASP.NET
          Date: Mon, 11 Apr 2011 18:51:57 GMT
          Content-Length: 172
          ----------------------------------------------------------
          http://example.com/resource/ //Redirects as a GET, loses all post data

          GET /resource/ HTTP/1.1
          Host: example.com
          User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
          Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
          Accept-Language: en-us,en;q=0.5
          .....


          We don’t care what happens after that . . . .
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            I seem to recall there’s something about IIS and rewriting urls that makes post data go all crazy and disappear...

            Can’t find where I got that from, but you may want to check out the Windows hosting forum..
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 25357
              • 92 Posts
              Thanks, and have been searching but it’s not the issue. At least, that I can tell. With the rewrite pointed to my "test script" the post data is all present in the rewrite. When I point the rewrite to modx (index.php) I get the 302 and redirect, causing the second GET request. The post data is (appears to be?) lost there.

              Edit: If you’re referring to this,

              http://support.microsoft.com/kb/956578/en-us

              That’s in reference to a custom 404 - which I avoid at all costs for rewriting . . . 404’s are supposed to be 404’s. This is not a 404 page.
                • 25357
                • 92 Posts
                I’ve figured out the character that’s causing it, I’ve just no idea **what** is causing it or how to fix it.

                Furthermore I’ve compared this against my Linux installations, they exhibit the same behavior - it just doesn’t cause the forms to fail.

                TRAILING SLASH.

                Form is on every page. On pages like this

                resource/

                I forced the form to have a slash, like so:

                <form action=" . URL . "/ method="post">

                Worked fine. Thinking I had a solution, I nav’ed to some pages that didn’t have the slash:

                resource

                Form post data fails. When I removed the slash from the form on those pages, those forms started working again and the ones with slashes don’t.

                Perplexed (and pi**ed off smiley ) I looked at some of my Linux installs, and sure enough, some of the navigations have slashes, some don’t, but it’s always the same resources in any give nav, like

                <a href="resource/">Resource 1</a></li>
                <a href="resource2/">Resource 2</a></li>
                <a href="resource3">Resource 3</a></li>
                <a href="resource4">Resource 4</a></li>
                <a href="resource5">Resource 5</a></li>

                I’d never noticed this before, but it’s in all my Linux installs, all of them. I don’t see any differences in the way the resource is set up, and of course don’t have a slash in the resource alias. I use WayFinder, maybe this is the problem, off to see if I can track this one down . . .



                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  What are your content type settings?

                  If you have the HTML content type set to nothing, and the container suffix (in system settings) to a trailing slash like default, that could be a reason for the slash being added to some resources - as they’re containers.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • 25357
                    • 92 Posts
                    Yes, text/html and "empty" extensions - and I went right where you are, thinking it was "container suffix" - but alas. Some of them are containers, and some are not. And some of the containers with children have no slash at the top level . . . lol

                    It doesn’t matter which (much, anyway) we have, slash or no slash - as long as I can figure out how to standardized them.

                    Then there’s the browser aspect (but I think it’s just for top level of the domain) some browsers will redirect a non-slashed example.com to example.com/. But the top level is not the problem here.

                    Anyway since last post have tried various browsers, same effect.

                    Funny how it doesn’t present a problem on Linux.

                    EDIT: AHHHH . . . thank you, this led to solving at least that mystery.

                    Although the "parents" contained children pages, I looked a little closer at a little-visited tab in the resource edit: Page Settings. Some of these "parents" have the container checkbox unchecked. That was the controlling factor on the slashes.

                    A little confused as to why you’d be able to create a "parent" containing children without it being a container by default, or even how some of these are containers and some are not (I’d clearly not known to set that checkbox,) I think this will at least lead the way to fixing this particular issue.