We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51428
    • 42 Posts
    Hello. Please, give me a piece of advice on what .htaccess should look like in order to get the best security from it. I mean all the .htaccess files that should be on a modx site.
    For example I have this for /core directory:
    IndexIgnore *
    Redirect /core http://www.google.com
        <Files .htaccess>
            Deny from all 
        </Files>

    Is that enough? Should I add something else?
    And what about the other .htaccess files (the one that is in the site's root directory, for instance)?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The most secure way to handle the core is to move it outside of the web root.
      https://rtfm.modx.com/revolution/2.x/administering-your-site/security/hardening-modx-revolution
        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
        • 1343 ☆ A M B ☆
        • 2,213 Posts
        If you aren't wanting to move the core outside of the webroot (recommended), the next best option would be doing this:

        Order Allow,Deny
        Deny from All
        
          Patrick | Server Wrangler
          About Me: Website | Tweets |  MODX Hosting
          • 51428
          • 42 Posts
          Just like this?
          IndexIgnore *
          Redirect /core http://www.google.com
              <Files .htaccess>
                  Deny from all 
              </Files>
          Order Allow,Deny
          Deny from All
            • 51428
            • 42 Posts
            The most secure way to handle the core is to move it outside of the web root.
            Agree. But how will I upgrade the engine after this? Won't it bring me additional headaches (if an upgrade script doesn't find the "core" where it should be)? I'm always a bit worried about customizing such things - you never know what it may turn to.
              • 51428
              • 42 Posts
              Btw,
              Order Allow,Deny
              Deny from All

              What is the idea of allowing first and deniing then? Why not this?:
              Order Deny, Allow
              Deny from All
                • 36816
                • 109 Posts
                Quote from: takamaro at Dec 08, 2015, 04:03 PM
                how will I upgrade the engine after this? Won't it bring me additional headaches (if an upgrade script doesn't find the "core" where it should be)?

                During upgrade, when you run setup, the process will ask you for the path to the core if it can't find it in document root. Once you tell setup where it is, it proceeds onward from there.

                Every Revo. installation I've ever done, I've put the core outside of document root. Upgrade has never been a problem.
                  • 51428
                  • 42 Posts
                  Upgrade has never been a problem.
                  Well, if so, I'll do that for safety.
                    • 1343 ☆ A M B ☆
                    • 2,213 Posts
                    Quote from: takamaro at Dec 08, 2015, 04:10 PM
                    Btw,
                    Order Allow,Deny
                    Deny from All

                    What is the idea of allowing first and deniing then? Why not this?:
                    Order Deny, Allow
                    Deny from All

                    It just locks things down better. You can get content in some cases with the reverse order.
                      Patrick | Server Wrangler
                      About Me: Website | Tweets |  MODX Hosting
                      • 3749
                      • 24,544 Posts
                      Quote from: takamaro at Dec 08, 2015, 04:03 PM
                      The most secure way to handle the core is to move it outside of the web root.
                      Agree. But how will I upgrade the engine after this? Won't it bring me additional headaches (if an upgrade script doesn't find the "core" where it should be)? I'm always a bit worried about customizing such things - you never know what it may turn to.

                      The UpgradeMODX extra reads the config.inc.php file and copies all the files to the correct locations regardless of where you put them. Setup will still ask you where the core is (I don't know why -- it should also be able to read the config file), but that's the only inconvenience.
                        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