We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31337
    • 258 Posts
    I’d be a big fan of getting rid of the current .htaccess method to manage friendly URLs. It seems like there is an easier way to manage this via an internal module that intercepts requests and rewrites them based on pre-defined rules. This way both access and error pages could be logged properly and arbitrary re-writing rules are possible.

    Thoughts?
      • 32963
      • 1,732 Posts
      Sounds great but I have very little rewrite skills son can’t contribute there at all.

      With the new events will it indeed be possible to activate a plugin/module to handle url rewrites
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 25663 MODX Staff
        • 12,272 Posts
        Raymond, I have no idea! But I bet I can find someone that does... wink
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 31337
          • 258 Posts
          Quote from: xwisdom at Nov 08, 2005, 10:25 AM

          Sounds great but I have very little rewrite skills son can’t contribute there at all.

          With the new events will it indeed be possible to activate a plugin/module to handle url rewrites

          Are there any docs on the events model yet? The pseudo code to deal with this is pretty simple (in my head at least grin) but I have no idea where to start looking in the ModX codebase.
            • 25663 MODX Staff
            • 12,272 Posts
            Quote from: vbrilon at Nov 08, 2005, 10:22 AM

            I’d be a big fan of getting rid of the current .htaccess method to manage friendly URLs. It seems like there is an easier way to manage this via an internal module that intercepts requests and rewrites them based on pre-defined rules. This way both access and error pages could be logged properly and arbitrary re-writing rules are possible.

            Might check out this article, but skip the second page (as every hit becomes an error page!!!): http://www.sitepoint.com/article/search-engine-friendly-urls

            We’d need a separate module/plugin to handle IIS servers, though.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 25663 MODX Staff
              • 12,272 Posts
              Victor, feel free to use pseudo code in explaining or discussing anything. (Victor is a Perl fiend and I would not be surprised to see him claim he can reproduce MODx in 12 lines of Perl ... wink )
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 31337
                • 258 Posts
                Quote from: rthrash at Nov 08, 2005, 10:39 AM


                Might check out this article, but skip the second page (as every hit becomes an error page!!!): http://www.sitepoint.com/article/search-engine-friendly-urls

                We’d need a separate module/plugin to handle IIS servers, though.

                Raymond, I am not so worried about *how* to handle the rewrite -- that’s the easy part. I am worried about where to dig in the guts of ModX to capture a "URL Request" event (or whatever it’s called) and how I can handle that event programaically. Make sense?
                  • 32963
                  • 1,732 Posts
                  Victor,

                  We don’t have an event for the Rewrite URL as yet but you can still go ahead and test it as you would a normal PHP app.

                  See here for a plugin example:
                  http://www.modxcms.com/plugin-examples.html

                  Ryan you might want to sen Victor a copy of the developer’s guide so he can have a list of the events.
                    xWisdom
                    www.xwisdomhtml.com
                    The fear of the Lord is the beginning of wisdom:
                    MODx Co-Founder - Create and do more with less.
                    • 31337
                    • 258 Posts
                    Hey! That’s cool. In fact I think the Page-Not-Found Redirector is sort of what you need. The logic works something like this:
                    - URL request for /foo/bar
                    - The plugin looks in the internal registry of friendly URLS, and figures out which page is "really" being requested.
                    - Then that page is rendered and sent back to the browser with a 200 status. Apache logs it as an access on that page
                    - If there’s no such mapping, then the plug in sends back a 404 status, Apache logs an error

                    I think the hard part is already done btw -- you’re already maintaining a mapping of page names to friendly URLS. Expose that to this plug in and you’re in business.
                      • 22303 MODX Staff
                      • 10,725 Posts
                      I don’t think we should mess with the friendly URL stuff yet, and mod_rewrite is absolutely the best place to do this now. I honestly can’t even conceive of a proper way to do it without mod_rewrite, because it’s the only way to get everything through one index.php file when no other physical files exist on the server. Otherwise, the webserver could never get the request to MODx...or am I missing something? (i.e. who’s handling the request for /foo/bar/ and how does it know to handle it?)