We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7804
    • 80 Posts
    We have had major headaches at times with the rewrite rules in our base directory’s .htaccess file (the one that comes with MODx for friendly URLs). For instance, we have a separate non-MODx ecommerce engine in a separate directory that was throwing us MODx’s 404 page when we tried to access the backend (something like https://www.domain.com/store/admin/index.php). We found a workaround for this without solving the problem, but today we had a similar issue. We have a folder for beta downloads of our software, which is password-protected via an .htaccess file similar to the following:

    AuthType Basic
    AuthName "User Name"
    AuthUserFile "/directory/to/passwd"
    require valid-user
    


    Every time tried to access this folder, we kept getting the 404 page from MODx. Even adding "RewriteEngine Off" to the .htaccess file didn’t help. Commenting require valid-user out of the file, however, made it go away (but then we didn’t have password protection for the subdir). So obviously it was being caused by something to do with authentication.

    So we did some Googling and came across this post:

    http://codeigniter.com/forums/viewthread/56677/#364483

    I figured out how to fix this. When you do a basic authentication with htaccess the server will return a 401 code. This appears to prompt the server to send a file called 401.shtml to the browser. I added the ‘401.shtml’ to my htaccess RewriteCond and that made it work.

    So, following this guy’s directive, we added this to our .htaccess file in our beta folder, but... it didn’t work. So we added it to the pre-packaged MODx .htaccess file in our base directory, and voila! it worked! We were prompted for the password to login to the beta directory.

    By the way, here is some more detailed information on how users are authenticated in Apache via HTTP:

    http://www.apacheweek.com/features/userauth

    I searched for the problem on these forums and saw that others have experienced the same thing, but I did not see that anyone found a solution. Perhaps this will help others who have ripped their hair out when trying to determine why this is happening; add this line of code to your base dir’s htaccess file:

    RewriteCond $1 !^(401.shtml)
    RewriteRule ^(.*)$ /index.php/$1 [L]


    This may be something that the developers would want to include (commented with an explanation) in the pre-packaged htaccess file for fURLs, since this really gave us a scare when we couldn’t access our shopping cart’s back end.
      • 27541
      • 29 Posts
      just wanted to thank you for posting this -- it was the only place i found a solution that worked! many many thanks!
      st