HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=25)
-   -   nginx rewrite (http://www.howtoforge.com/forums/showthread.php?t=58130)

onastvar 30th July 2012 17:53

nginx rewrite
 
I'm using the following nginx Directives in my ISPConfig for one of my websites where I run WordPress and it works fine.

Code:

location / {
                try_files $uri $uri/ /index.php?$args;
          }

      # Add trailing slash to */wp-admin requests.
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;

      location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
      }
# Deny public access to wp-config.php
location ~* wp-config.php {
    deny all;
}

I'm trying to figure out how can I setup nginx rewrite so I can install another CMS (WordPress, Joomla, etc.) within same website, in another folder. Anyone has similar setup, please advise?

falko 31st July 2012 19:25

You can try nested locations for each folder, e.g. like this:

Code:

location / {
                try_files $uri $uri/ /index.php?$args;

              # Add trailing slash to */wp-admin requests.
              rewrite /wp-admin$ $scheme://$host$uri/ permanent;

              location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
              }
              # Deny public access to wp-config.php
              location ~* wp-config.php {
                    deny all;
              }

}

Then try the same for a subfolder:

Code:

location /subfolder {
                try_files $uri $uri/ /index.php?$args;

              # Add trailing slash to */wp-admin requests.
              rewrite /wp-admin$ $scheme://$host$uri/ permanent;

              location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
              }
              # Deny public access to wp-config.php
              location ~* wp-config.php {
                    deny all;
              }

}



All times are GMT +2. The time now is 19:13.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.