We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44195
    • 293 Posts
    Hi,
    I've gone to make some changes to a modx site that's been up for about a year.
    It's all working fine as is but if I create a new resource and attempt to view it in the web context, I'm getting a 503 error.
    It doesn't matter if I'm logged in as an administrator or anonymous.
    I've tried deleting the cache, flushed all permissions and sessions.
    I have friendly urls on with both an english and chinese context.

    Update: If I turn friendly urls off I can access the page!

    Does anyone know what might be the cause of this? could it be to do with rewriting in the .htaccess file? [ed. note: muzzstick last edited this post 9 years, 9 months ago.]
      I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
      Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
      • 44195
      • 293 Posts
      Ok it's definitely the rewrite rule causing the problem but I only have a rudimentary understanding of Apache's 'RewriteCond' and 'RewriteRule' so I was hoping someone could point me in the right direction.

      This site is using the Babel extra and has some custom rewrites in the .htaccess file.
      i.e.
      # redirect all requests to /ch/favicon.ico to /favicon.ico
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(en|ch)/favicon.ico$ favicon.ico [L,QSA]
         
      # redirect all requests to /ch/assets* to /assets*
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(en|ch)/assets(.*)$ assets$2 [L,QSA]
        
      # redirect all other requests to /ch/* to index.php and set the cultureKey parameter
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(en|ch)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
      


      It is using the context switching method described at http://www.multilingual-modx.com/blog/2011/seo-friendly-multilingual-websites-with-modx-and-babel.html with a gateway plugin that sets the 'cultureKey'

      This all works great for this single-page site that just uses ajax to load additional resources.. but if I create a new resource that is requested with it's own friendly uri it spits out the 503 error.

      I know that it is the above rewrites causing the problem because I commented them out and tried the stock rewrite that is supplied by MODx
      # The Friendly URLs part
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      


      and I can then access the new resources correctly. But of course it breaks the context switching and I'm stuck with only the default language.

      How can I fix this without breaking the multi-lingual functionality?
        I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
        Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
        • 44195
        • 293 Posts
        I've discovered that I can create resources and view them in the Chinese (ch) context but it's just not working in the default English (web) context if that helps narrow the problem down...
          I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
          Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
          • 44195
          • 293 Posts
          I'm now having a go at getting the following plugin to work. I saw that Susan recommended it in another thread.
          https://gist.github.com/gadamiak/3812853

          Should this be tied to the 'onhandlerequest' event?
          As this makes sense to me but it's telling me my $_REQUEST['q'] has an undefined index. [ed. note: muzzstick last edited this post 9 years, 9 months ago.]
            I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
            Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com