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

    Maybe i'm overlooking something here, but when i try to do a fairly easy job of rewriting URL's, it als makes my backend to malfunction.

    e.g. i have this (as given in the basic htacces file)

    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    


    And preventing acces to manager and assets folder like so:
    RewriteRule ^(manager|assets)/*$ - [L]
    


    While on the frontend it rewrites like i want it to, the backend then stops working, all i see there is the menu bar and where the elements/documents/ menu should be, there is now unidentified.

    I have also tried to put the RewriteEngine Off in the .htacces in the manager folder with the same result as above.
    Can someone please advice on this?
      • 39194
      • 149 Posts
      See error log in browser console. (F12, Ctrl+Shift+I, Ctrl+Shift+K .. depends on your browser)

      RewriteEngine Off is good solution, you don't need to change you RewriteRule.
        • 40092
        • 265 Posts
        Working with Rewrite off is something i prefer too. smiley

        Console shows:
        GET http://localhost/cubarevo/connectors/lang.js.php?ctx=mgr&topic=topmenu,file,resource,welcome,configcheck&action= 404 (Not Found) localhost:11
        GET http://localhost/cubarevo/connectors/layout/modx.config.js.php?action=&wctx=mgr 404 (Not Found) 
        


        I read somewhere this was sort of a bug when using no www. prefix. But i'm running on a localhost xampp here.
          • 40092
          • 265 Posts
          Dived into it again after coffee. We should offcourse exclude the connectors folder from our Rewrite rules like so:

          RewriteRule ^(assets|connectors) - [L]
          • Did you use the entire Friendly URLs part?

            Eg:
            # The Friendly URLs part
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


            The second and third line should prevent the rewrite from even thinking about triggering if the file or directory being request actually exists. I've never had to update the rewrite rule to exclude those folders in the past 5 years tongue
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 40092
              • 265 Posts
              Yep, i actually do have those lines exactly in the .htacces.

              # For full documentation and other suggested options, please see
              # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
              # including for unexpected logouts in multi-server/cloud environments
               
              #Options +FollowSymlinks
              RewriteEngine On
              RewriteBase /cubarevo/
               
              # Fix Apache internal dummy connections from breaking [(site_url)] cache
              #RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
              #RewriteRule .* - [F,L]
              
              # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
              #RewriteCond %{http_host} ^naar-cuba.nl
              #RewriteRule ^(.*)$ http://www.naar-cuba.nl/$1 [R=301,L]
              
               
              # Exclude /assets and /manager directories from rewrite rules
              RewriteRule ^(assets|connectors) - [L]
               
              RewriteRule ^reizen/(.*)$ http://www.naar-cuba.nl/vakantie/$1 [R=301,L]
              
              # For Friendly URLs
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteCond %{REQUEST_FILENAME} !^(.*).(js|jpg|css|png|gif)$
              
              RewriteRule ^vakantie/(.*)/(.*)\.html$ accommodatie.html?alias=$2&case=specifiek [L]
              RewriteCond %{REQUEST_FILENAME} !^(.*).(js|jpg|css|png|gif)$
              RewriteRule ^vakantie/(.*)\.html$ search.html?case=zoek&reis=$1 [L]
              RewriteCond %{REQUEST_FILENAME} !^(.*).(js|jpg|css|png|gif)$
              RewriteRule ^offerte-accommodatie/(.*)\.html$ offerte-accommodatie.html?alias=$1 [L]
              RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
              
              
              RewriteRule ^(.*)\.xml$ index.php?q=$1.xml [L,QSA]
              
              
              [ed. note: thapriest86 last edited this post 11 years, 5 months ago.]
              • I think the way you've used it may only apply the !-f and !-d rules to the first RewriteRule only and not to the RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] one
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 40092
                  • 265 Posts
                  Ah, i see.
                  Just like the RewriteCond for the file extensions it should be a repetetive rule for each of the rewriterules.

                  Excluding the connectors folder just once would be a cleaner and shorter way of achieving the same, what would be the cons of doing it that way?