We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    So this is the situation I’m at (it’s a bullet list tongue):


    • The site is hosted on a shared host (cPanel controlled)
    • As an upgrade to the normal package, I have a SVN+Trac bundle enabled (RVSkin)
    • Accessing Trac is done by "domain.tld/trac"

    Now this is where things get interesting...

    As I mentioned, the site is on a shared host so the Trac installation is done by alias-ing the trac.cgi on the shared part and forcing it to use local configuration per-domain.
    With the Friendly URLs, /trac/ doesn’t "exist" so excluding it works enough to get the Trac accessible.
    Trying to log in with the implemented HTTP auth. thingy (/trac/login), Friendly URLs ignore the Trac ignore set before and god knows where the server is looking for the login at that point.

    Using Trac on a sub-domain might be a possibility but it requires changes done by the provider to the shared environment.

    So, is there any mod_rewrite magic to stop the friendly URLs redirect to stop hijacking the login and trac in total as trac is simply alias for trac.cgi on shared folder and login is probably done by a <Location>-tag somewhere in the depths of the server. (send teh codez)
    I tried to fiddle around with my poor knowledge of RegExp and mod_rewrite with the help of Google but to no avail...
    • Have you tried this, above the main MODx rewrite statement:

      # Exclude /assets and /manager directories from rewrite rules
      RewriteRule ^(manager|assets|trac) - [L]
      
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 34162
        • 1 Posts
        Adding Trac to the rewrite exclude results in a too many forward attempts error.

        While removing Trac from the exclude and commenting out the lines taking care of Friendly URLs the Trac works fine.
        • Another suggestion I have is to use a RewriteCond right above the main modx rewrite.

          RewriteCond %{REQUEST_FILENAME} !trac\/ [NC]
          


          And just for the heck of it, maybe we can try the "-l" flag which tests for symbolic links.
          RewriteCond %{REQUEST_FILENAME} !-l
          


          So that whole block would become something like
          # For Friendly URLs
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-l
          RewriteCond %{REQUEST_FILENAME} !trac\/ [NC]
          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
          


          This is just a stab in the dark. If you have the patience, I suggest grabbing a thermos of coffee and reading the mod_rewrite documentation. This quote from the documentation says it all: "The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail."

            Mike Schell
            Lead Developer, MODX Cloud
            Email: [email protected]
            GitHub: https://github.com/netProphET/
            Twitter: @mkschell
            • 34162
            • 1 Posts
            A stab in the dark it really was.

            By far excluding the trac above the friendly urls works (had deleted the error pages and forgot to update the docid, go me) but only for the trac itself.
            The login is still producing a 404, with the following bits in the .htaccess
            # Exclude /assets and /manager directories from rewrite rules
            RewriteRule ^(manager|assets|trac) - [L]
            
            # For Friendly URLs
            RewriteCond %{REQUEST_FILENAME} !-f
            RewritCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-l
            RewriteCond %{REQUEST_FILENAME} !trac\/ [NC]
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


            Might experiment more tomorrow with a Moccamaster on standby.
            Yet I’m still wondering if the login is done with a <Location>-bit, will the mod_rewrite acknowledge the fact that /trac/login is pointing to a virtual path/file. As far as my knowledge of mod_rewite goes, you should be able to pick up the login bit on REQUEST_URL as, if my memore doesn’t fail hard one me, that bit should be the full path the browser is requesting, eg. index.php on the site’s root would be /index.php

            Edit: After poking with various methods, it occurred to me that why not check for the referer... no need to say it works... sort of: you can login, only if you do it from the trac, direct login will just spew out a 404.
            "Final" version of the rewrite I currently have is the following
            # Exclude /assets and /manager directories from rewrite rules
            RewriteRule ^(manager|assets|trac) - [L]
            
            # For Friendly URLs
            RewriteCond %{HTTP_REFERER} !.*trac.*
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-l
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]