• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

WordPress ( TotalCache ) + xenforo rewrite rule on nginx

Blandt

Well-known member
#1
This nginx configuration file will rewrite properly for both Wordpress / W3 TotalCache and Xenforo nested in the same folder like this :
/home/you/public_html/domain.com/public/community so the URL is like so : www.domain.com ----> Wordpress
and www.domain.com/community ------> Xenforo

You will need to be running nginx 0.7 and above

HTML:
server {
  listen          80;
  server_name    domain.com;
  rewrite ^      http://www.domain.com$request_uri permanent;
      }
server {
            listen          80;
            server_name www.domain.com;
                        root  /home/you/public_html/domain.com/public;
                        index  index.php;
location / {
if (-f $request_filename) {
        break;
}
set $totalcache_file '';
set $totalcache_uri $request_uri;
if ($request_method = POST) {
  set $totalcache_uri '';
}
if ($query_string) {
  set $totalcache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
  set $totalcache_uri '';
}
if ($totalcache_uri ~ ^(.+)$) {
  set $totalcache_file /wp-content/w3tc-$http_host/pgcache/$1/_default_.html;
}
if (-f $document_root$totalcache_file) {
  rewrite ^(.*)$ $totalcache_file break;
}
if (!-e $request_filename) {
        rewrite . /index.php last;
}
  location /community/ {
        try_files            $uri $uri/ /community/index.php?$uri&$args;
    }
    location /community/(data|internal_data|library)/ {
    internal;
    }
}
location ~ \.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME    /home/you/public_html/domain.com/public/$fastcgi_script_name;
    fastcgi_param PATH_INFO              $fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
                      }
}
Of course you need to edit the last line to include your FastCGI file and edit your path I have also added the canonical rewrite rule to redirect the domain.com to www.domain.com
Reply with any special configuration