My webapps, like /roundcube are not working when I try to setup custom wordpress rewrite in my nginx.conf


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » CustomBuild » CustomBuild 2.0 » Nginx

My webapps, like /roundcube are not working when I try to setup custom wordpress rewrite in my nginx.confLast Modified: Sep 6, 2014, 11:02 pm
If you're trying to setup WordPress redirects in your user nginx.conf file, but this breaks your webapps links, like /roundcube, you must do it in a specific way, or your WP rewrites are going to override the /roundcube settings, thus breaking them.

Do the following to setup your WP settings for a basic nginx setup (proxy setup: see below):

cd /usr/local/directadmin/data/templates/custom
cp ../nginx_server.conf .

and then edit the custom copied nginx_server.conf.

Find the line at the end of the server entry that looks like this:

       include /etc/nginx/webapps.conf;

and immediate after it (at the very end of the server, add this code:

|*if HAVE_NGINX_PROXY!="1"|
       location /
       {
               rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
               if (!-e $request_filename) {
                       rewrite  ^(.+)$  /index.php?q=$1  last;
               }
       }
|*endif|

Where the point of this is that:
1) It's within a location / directive.
2) It comes after the include of the webapps.conf.

If you use subdomains or https then repeat everything on the other 3 files, eg:

nginx_server_secure.conf
nginx_server_secure_sub.conf
nginx_server_sub.conf



Once you're satisfied with your settings, issue a rewrite on the nginx configs:

cd /usr/local/directadmin/custombuild
./build rewrite_confs




If you are running the proxy setup,
If you are running the proxy setup, no nginx.conf customization is needed, as .htaccess files are effective in this case.



For more information on exactly what you need to put within the location / section, please refer to the nginx WordPress documentation:
http://wiki.nginx.org/WordPress

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST