We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12379
    • 460 Posts
    How do I get modx to ignore my cgi-bin? I’m getting an error page generated by modx when I try to access a script!

    (I’m using Apache on Linux server)
      Mostly harmless.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      How are you accessing the script? I’m using a perl script (Dada mail) in a module and it works fine.
        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
        • 12379
        • 460 Posts
        Actually it’s a perl script that functions independently of Modx. Just load the url into browser to fire up the script but modx overrides the url and throws out a 404.

        eg
        http://www.domainname.com/cgi-bin/csvedit.pl
          Mostly harmless.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Try copying the .htaccess file that’s in the /manager folder to your /cgi-bin folder.
            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
            • 12379
            • 460 Posts
            thank you - yes of course!

            only problem now is when I password protect that same directory with additional code below the problem reoccurs.

            RewriteEngine Off

            AuthType Basic
            AuthName "••PRIVATE••"
            AuthUserFile "/home/xxxxx/.htpasswds/public_html/cgi-bin/private/passwd"
            require valid-user
              Mostly harmless.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              As to that, I have no ideas.
                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
                • 12379
                • 460 Posts
                OK, there’s a known problem with mod_rewrite and .htpasswd, so the closest solution is the last two lines here:

                # The Friendly URLs part
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d

                #Exclude directory from Mod_Rewrite
                RewriteCond %{REQUEST_URI} !^/directory(/.*)?$ [NC]
                RewriteRule .* rewrite?%{REQUEST_URI} [L]


                ...where ’directory’ is the name of the directory needing to be ignored by mod_rewrite - my cgi-bin in this instance.
                  Mostly harmless.
                  • 12379
                  • 460 Posts
                  After doing some testing I wouldn’t recommend putting the above code into the root level .htaccess file, as it does some weird sh*t to the web site. Instead, I put the code below into an .htaccess file in the cgi-bin. Works a treat now - doesn’t clash with .htpasswd.

                  #Exclude directory from Mod_Rewrite
                  RewriteCond %{REQUEST_URI} !^/directory(/.*)?$ [NC]
                  RewriteRule .* rewrite?%{REQUEST_URI} [L]
                    Mostly harmless.