We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hi, I need to create a "archive" section for a website where to freeze previous years.

    I created a new context "archive2013" and a folder "archive2013" in the web root, where I placed index.php and config.inc.php.

    I modified the Nginx web rules as follows:

    location /archive2013/ {
      rewrite ^/archive2013/(.*)$ /archive2013/index.php?q=$1 break;
    }
    
    location / {
        try_files $uri $uri/ @modx-rewrite;
    }


    But if I access to www.mysite.com/archive2013/ the webserver makes me download "index.php"...
    and so on, if I access to:

    www.mysite.com/archive2013/index.php?id=54 the webserver makes me download "alias_of_resource_54.html"

    how can I adjust the web rules?
    Thanks!
      TilliLab | MODX Ambassador
      website
    • ok, may be I found a solution with this rule:

      location /archive2013/ {
         index index.php;
         rewrite ^/archive2013/(.*)$ /archive2013/index.php?q=$1 last;
         try_files $uri $uri/ @modx-rewrite;
      }
      
      location / {
          try_files $uri $uri/ @modx-rewrite;
      }
      


      I don't understand very well the Nginx logic, but after several attempts it works... smiley
        TilliLab | MODX Ambassador
        website
      • ok, I also added:

        location /archivio2013/assets/ {
        }


        to make Nginx ignore the files, css and so on inside assets
          TilliLab | MODX Ambassador
          website
        • Sorry for so many posts...

          Semi-final code is:

          location /archive2013/ {  
             rewrite ^/archive2013/(.*)$ /archive2013/index.php?q=$1 last;
          }
          location /archive2013/assets/ {
          }
          location / {
              try_files $uri $uri/ @modx-rewrite;
          }


          it works everything but the homepage of the new context...if I browse to http://www.mysite.com/archive2013/ I have a loop redirect...
            TilliLab | MODX Ambassador
            website
          • Well, thanks to modxcloud staff I found a cleaner solution using 2 plugins for getaway across contexts,
            if interested, you can read about them here: http://forums.modx.com/thread/77890/context-routing-based-on-a-subfolder-in-the-url-path

            and now I use again the default Nginx rules.
              TilliLab | MODX Ambassador
              website