We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5158
    • 39 Posts
    Hello all,
    I hope I’ve made the right choice in choosing this forum for my problem.
    Does MODx allow for aliasing in Apache? That is to say; I have a problem
    getting MODx to return Friendly URL’s on my site. I have made every possible
    combination of configuration options I can concieve. All without success.
    So, I figure that MODx must not like (handle) directory aliasing well (correctly).
    System:
    FreeBSD-5.4
    Apache-1.3
    PHP-4.42
    MySQL-4.1.18_2

    Directory-Aliased:
    <IfModule mod_alias.c>
    # //////////////////////////////////////////////////////
    # // Alias for MODx CMS (board)
    Alias /board/ "/usr/local/www/modx/"
    </IfModule>

    So, if I type the URL:
    http://my.domain.tld/board/
    I get the MODx installation as intended. However, I am *completely* unable to
    get the Friendly URL’s to work. The only *friendly* thing returned when Friendly
    URL’s is enabled; is a 404 document, which *isn’t* very friendly. smiley

    Thank you for all your time and consideration.

    --Chris H.
    • Check out the contents of the ht.access file and add those to the mix... MODx currently needs the mod_rewrite directives to get FURLs to work.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 5158
        • 39 Posts
        Hello, and thank you very much for your response.
        I persued that option early on in my quest to get Friendly URL’s
        working - to no avail. sad
        The file (as it should) has read only permissions for thw webserver only.
        It’s contents reads as follows:
        .htaccess
        RewriteRule ^(.*)$ /usr/local/www/modx/index.php?q=$1 [L,QSA]

        According to the notes contained in it:

        # If your MODx installation is in a subdirectory, change the following
        # line to match the physical path to the "root" of the site as follows:

        my line should be correct. So the only other thing I felt might be the issue
        was my aliasing it’s location. My .htaccess line is correct for my MODx
        installation, isn’t it?

        Thank you again for all your time and consideration.

        --Chris H.
        • You need the web path (i.e. relative URI) to the modx installation. If the alias is specifying the web root as /usr/local/www/, then the original .htaccess settings should be fine:

          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


          If the web root were /usr/local/www/modx/ then you would prepend /modx/ to the RewriteRule target...

          RewriteRule ^(.*)$ /modx/index.php?q=$1 [L,QSA]


          If that doesn’t work, I suggest searching more thoroughly on the subject here in the forums or search for more general information on configuring mod_rewrite with Apache (especially in regards to using mod_alias); this topic has been covered from many angles here previously, and you’re likely to find your solution in these posts...

          [NOTE: I corrected the reversed information as reported by sottwell, so it should be indicated properly now, even though my ignorance of how mod_alias works didn’t help much here... cool]
          • I think you have that reversed, Jason...
              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
              • 5158
              • 39 Posts
              Jason, thank you very much for your reply. But your suggestion(s)
              aren’t appropriate for my delemna. I am well versed in Apache’ s mod_rewrite
              voodoo. As a matter of fact, I have written a rule to deal with all the,
              ahem... shall we say "naughty" individuals out there looking to exploit/
              compromise all the servers using wordpress, horde, phpnuke, etc, etc...
              whose libraries, modules have security issues in them. They scan the
              hosts for the files. I get some 500 attempts/ day. I deal with these
              creeps by RegExp’ing the the frequent patterns of their GET requests and
              reverse them into a POST and fill the post with 50Mb of raw binary data
              generated from /dev/random. See, I can be even nastier than they are.
              Well, it only takes but once for them to decide not to include my IP block in
              their scans. Anyway, back to the subject at hand:
              My problem was with the Alias portion of the request.
              If you look back at my original post. You’ll notice I host MODx out of an
              aliased alias, which is a subdirectory "to boot" eg;

              # ///////////////////////////////////////////////////////
              # // Alias for MODx CMS (board)
              Alias /board/ "/usr/local/www/modx/"

              So, as it turns out, the propper cure in this situation is to put the following
              in the .htaccess file:

              RewriteEngine On
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              #
              RewriteRule ^(.*)$ /board/index.php?q=$1 [L,QSA]

              and all works as intended.

              Could an administrator for modx please create a thread/ section
              in the forum with the title:
              mod_rewrite, regexp, .htaccess - it’s easy to confuse MODx
              and then move all the related threads currently following this topic
              into it? I was able to solve my problem and have been hosting for
              some 18 yrs. now and would be more than happy to monitor that
              section and pitch in.

              A big thanks to everyone that took the time to respond.

              Best wishes.

              --Chris H.
              • Chris it sounds that you’re definitely the master rewrite-meister... we’d love to have your input on how we should change the Friendly URL solution to make it easier or more robust. Thanks!

                P.S.
                Any reason not to just rename this thread per your suggestion?
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 5158
                  • 39 Posts
                  Quote from: rthrash at May 21, 2006, 02:25 PM

                  Chris it sounds that you’re definitely the master rewrite-meister... we’d love to have your input on how we should change the Friendly URL solution to make it easier or more robust. Thanks!
                  Thanks for the props Ryan. smiley I’ll have to give that some thought. But initially, I
                  think that devoting a section to mod_rewrite, regexp, .htaccess would probably
                  provide the best solution where applied to MODx-ism’s. Naturally, adding the
                  most asked about sections in the forum to the MODx documentation
                  would likely be benifitial too. But then again; no. I mean; who reads the directions
                  anyway. wink

                  Quote from: rthrash at May 21, 2006, 02:25 PM

                  P.S.
                  Any reason not to just rename this thread per your suggestion?
                  Nothing of course. smiley But ultimately, I think it would be even better if all the
                  *current* questions relating to th(is||ese) topics (would be best || should be)
                  moved to this new (heading || section). Don’t you think? I’d be happy to monitor
                  this (section || area) and respond to their needs. Oh! It just occurrs to me as
                  I am typing this, that I could whip up a (or alter the one that’s already in it)
                  sniffer that provides proposed entries for the .htaccess file based on it’s findings.
                  So that the user can copy them for later use in it. This could be done during install
                  and be based (derived) in part, from the answers provided for the regular installation.
                  It (or better; another) could be provided in the FURL section of the administration
                  area. I’ll need to give all this deeper consideration/ thought. But what do you think?

                  Thanks again.

                  --Chris H.
                  • I could whip up a (or alter the one that’s already in it)
                    sniffer that provides proposed entries for the .htaccess file based on it’s findings.
                    So that the user can copy them for later use in it. This could be done during install
                    and be based (derived) in part, from the answers provided for the regular installation.
                    It (or better; another) could be provided in the FURL section of the administration
                    area. I’ll need to give all this deeper consideration/ thought. But what do you think?

                    Sold! I like it a lot. smiley
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • Absolutely! It would be very easy to generate the file automatically from an FURL administration page and/or display the generated rules for users to copy and paste, based on file permissions. This is how WordPress does it and it is indeed a handy feature. I’m also considering some mod-rewrite independent (and error redirection independent for IIS) Friendly URL’s implementation for 1.0 and will take this in consideration in designing a generic rules generator/viewer for this.

                      This discussion is closed to further replies. Keep calm and carry on.