We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21387
    • 4 Posts
    Hi,
    I’m trying to password protect the content of a folder (insides assets). This folder contains word documents and pdfs. I have a hidden page that is password protected and that accesses the files. To make these more secure I tried adding a htaccess and htpasswd file to the folder. Unfortunately when a users clicks on the word dcument url this somehow creates a 404 error redirecting them to the homepage. I suspect a problem with the two htaccess files not working correctly together.

    Any ideas? Thanks a lot.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
        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
        • 21387
        • 4 Posts
        Thanks sottwell smiley

        unfortunately I’d like to make sure only people with a password can access the files.
        If I don’t manage with htaccess, maybe an add-on?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Maybe you need a secure download system like http://modxcms.com/extras/package/147
            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
            • 21387
            • 4 Posts
            I looked at it, but will it allow me to password protect the documents or just to count them and prevent access for some IPs?
              • 7231
              • 4,205 Posts
              You can password protect them. The files are served from a MODx document and you can protect the document just like you would any other MODx page.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 34108
                • 66 Posts
                Hi Nial, did yourself (or anyone else) end up finding a solution to this problem without having to use MODx’s inbuilt web user manager?

                I’m currently having the exact same problem and I’m 99% sure it’s being caused by these lines of code in the standard MODx .htaccess file (ver 1.0.4):

                Options +FollowSymlinks
                RewriteEngine On
                RewriteBase /

                When I remove the above lines from the root directory .htaccess file my .htaccess password protection on another folder works fine but then the site itself breaks so removing these lines isn’t an option.

                There must be a way around this - any .htaccess guru’s able to assist?

                Thank you smiley!
                Harmony
                  • 31339
                  • 1 Posts
                  hello

                  we had this problem and have not found a solution, but a workaround that worked for us is to create a subdomain for the folders that you want to make available and protect with htaccess files.

                  so if the modx enabled website is:

                  http://www.example.com/

                  and you want to give access to "public_html/myfolder". if there is no .htaccess file in there, then

                  http://www.example.com/myfolder

                  will work fine. but if you want to control access to it using a .htaccess file, we found that we had to create the corresponding subdomain and therefore provide access to the resource via this url:

                  http://myfolder.example.com/

                  it’s a bit of a hack but it works fine for us -

                  hope this helps until someone comes back with a "proper" solution...

                  viet
                    • 13306
                    • 19 Posts
                    I don't know if this has been covered more recently, but I'll resurect the old thread. I ran into the same problem using Evolution today and I stumbled into a solution after a snag I hit with directory permissions on some shared hosting.

                    Our servers are looking for a 401 Unauthorised page - and this happens not only when authentication fails but also if it's yet to be provided. It's this 401 page that isn't found, leading to a 404 and a redirect.

                    The fix it is to add an ErrorDocument line to the .htaccess file in the subdirectory like this:

                    ErrorDocument 401 /

                    That could also be ErrorDocument 401 /error-pages/404.html, or any path you like so long as the document exists.

                    I hope that's useful to someone.
                      • 3749
                      • 24,544 Posts
                      I had a similar problem. My host had placed files for that in the root directory (e.g., 401.shtml, 404.shtml, etc.), but I failed to copy them into the MODX root directory. That led to some weird errors and double requests (with different rewrite results) when a page wasn't found.



                      ---------------------------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                      MODx info for everyone: http://bobsguides.com/MODx.html
                        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