We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22640
    • 44 Posts
    Hi everyone,

    I’m searched around and can’t seem to find a good solution. I’m sorry of this has been talked about before.

    I have ModX installed with no fancy modules or plugins. Friendly URLs are on. I have a directory with files in it that I want to keep ’separate’ from ModX. In other words, I’m not using ModX to edit these pages. Just some straight editing and uploading. Therefore I have not ’created’ the pages on Manager.

    I want to password protect this directory using .htaccess. When I do so, the directory can’t be accessed and I am redirected to ModX 404 error page (the home page actually).

    I’m assuming there is some sort of ’conflict’ with the .htaccess file in the root that ModX is using for redirects etc.. etc..

    My question is:
    Can I password protect a directory using .htaccess that I want to keep independent from MoDx, and not get 404 error messages?

    Any help would be appreciated!

    Glenn
      • 263
      • 52 Posts
      The .htacess file that password-protects a directory is placed in that same directory and should not conflict with your MODx install. Here is a useful tutorial:
      http://www.javascriptkit.com/howto/htaccess.shtml
      and here is a tool for generating .htaccess and .htpasswd:
      http://www.tools.dynamicdrive.com/password/

      Cheers!
        • 22640
        • 44 Posts
        Quote from: abbeyroad at Jun 09, 2006, 09:22 AM

        The .htacess file that password-protects a directory is placed in that same directory and should not conflict with your MODx install. Here is a useful tutorial:

        Thanks abbeyroad.

        Unfortunately, it didn’t help. The htaccess file I have in the directory looks like this:

        AuthType Basic
        AuthName "Restricted Area"
        AuthUserFile /home/accountname/.htpasswds/admin/passwd

        require user admin


        I tried it by removing every line one at a time. The index page of the directory loads UNTIL I add the last line. If the last line is there, a 404 error page is displayed. Weird. If the last line is not there, it will load (not protected of course).

        Any suggestions anyone? Could it be the friendly URLs stuff?
        Glenn
          • 263
          • 52 Posts
          AuthUserFile /home/accountname/.htpasswds/admin/passwd
          Is this line the correct path to the AuthUserFile? As in:
          AuthName "Restricted Area" 
          AuthType Basic 
          AuthUserFile /home/accountname/.htpasswds/.htpasswd 
          require user username

          where .htpasswd is a plain ASCII text file with the following format:
          username:encryptedpassword

          - no spaces and ending with line-feed.

          If your paths and file formats are ok, no reason it should not work

          Cheers
            • 22640
            • 44 Posts
            Quote from: abbeyroad at Jun 10, 2006, 02:42 PM

            If your paths and file formats are ok, no reason it should not work

            Unfortunately that doesn’t seem to be the problem. Its related to ModX. As soon as I rename/delete/move the htaccess in the root directory associated with ModX, then the password protection works perfectly. When I put it back, 404 error shows up. Must be something with the Furls. Still working on it...see what I can do.
              • 22640
              • 44 Posts
              Quote from: panorama at Jun 21, 2006, 01:28 PM


              Unfortunately that doesn’t seem to be the problem. Its related to ModX. As soon as I rename/delete/move the htaccess in the root directory associated with ModX, then the password protection works perfectly. When I put it back, 404 error shows up. Must be something with the Furls. Still working on it...see what I can do.

              Still don’t know what causes it but did manager to get it working.
              Instead of using ’www.domain.com/admin’ I had to make a subdomain; ’admin.domain.com’ And it worked fine. Why? who knows. tongue
                • 6726
                • 7,075 Posts
                Strange... I have used .htpasswd files with MODx without any problem, so it’s definitely NOT MODx related...
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 17544
                  • 86 Posts
                    • 14779
                    • 256 Posts
                    I’m having the exact same problem.

                    Here is my .htaccess file:

                    AuthType Basic
                    AuthName "HEAV Images Gallery"
                    AuthUserFile /home/********/.htpasswds/gallery/.htpasswd
                    Require valid-use


                    ******** is replaced with valid dir name.
                    The above dir is outside my web site. Does that make a difference?

                    I know my passwd file is correct, and I have tried CPanel’s Password protected directory wizard, but it yields the same results - 404 error page as specified in MODx.
                      PM me to find out how you can get a FREE ipad 2!
                      • 25847
                      • 62 Posts
                      I too, am having the exact same issue. After going to this post (http://modxcms.com/forums/index.php/topic,12673.msg83998.html#msg83998) and trying the fix at the bottom I still have no success. How do we fix this issue?

                      The following is my .htaccess file:
                      AuthType Basic
                      AuthUserFile /home/username/site/slimstats/.htpasswd
                      AuthName "SlimStats"
                      require valid-user
                      ErrorDocument 401 /index.php
                      ErrorDocument 403 /index.php