The MU forums have moved to WordPress.org

My Nginx rewrite rules with wpmu, wp super cache, bbpress and sitemaps support (4 posts)

  1. johnnytee
    Member
    Posted 13 years ago #

    enjoy!

    server {
    listen 80;
    server_name _ bandpress.org *.bandpress.org;

    error_log /var/log/nginx/bandpress.org.error.log;
    access_log /var/log/nginx/bandpress.org.access.log;

    # Set this to off if you're hosting more than one site
    server_name_in_redirect off;

    #redirects 301
    rewrite /togodaddy$ http://www.kqzyfj.com/click-3348421-10378406 permanent;
    rewrite /towoothemes$ http://www.woothemes.com/amember/go.php?r=12635&i=b16 permanent;

    # Rewrite WordPress
    location /
    {
    gzip on;
    gzip_http_version 1.0;
    gzip_vary on;
    gzip_comp_level 3;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;

    root /var/www/bandpress.org;
    index index.php;

    #rewrite for sitemaps
    rewrite ^(.*/)?sitemap.xml /wp-content/sitemap.php last;
    #rewite for anyfont
    rewrite images/(.*)/(.*)\.png$ /wp-content/plugins/anyfont/img.php last;
    #rewrite for blog files
    rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1 last;

    # WordPress pretty URLs
    if (-f $request_filename)
    {
    expires max;
    break;
    }
    if (-d $request_filename)
    {
    break;
    }
    # WP Super Cache
    set $supercache_file '';
    set $supercache_uri $request_uri;

    if ($request_method = POST) {
    set $supercache_uri '';
    }

    # Using pretty permalinks, so bypass the cache for any query string
    if ($query_string) {
    set $supercache_uri '';
    }

    if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
    set $supercache_uri '';
    }

    # if we haven't bypassed the cache, specify our supercache file
    if ($supercache_uri ~ ^(.+)$) {
    set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
    }

    # only rewrite to the supercache file if it actually exists
    if (-f $document_root$supercache_file) {
    rewrite ^(.*)$ $supercache_file break;
    }

    #BBPress
    if (!-e $request_filename) {
    rewrite ^/forums/topic/(.*)$ /forums/topic.php last;
    rewrite ^/forums/forum/(.*)$ /forums/forum.php last;
    rewrite ^/forums/profile/(.*)$ /forums/profile.php last;
    rewrite ^/forums/view/(.*)$ /forums/view.php last;
    rewrite ^/forums/tags/(.*)$ /forums/tags.php last;
    rewrite ^/forums/rss/(.*)$ /forums/rss.php last;
    rewrite ^/forums/bb-admin/ /forums/bb-admin/index.php last;
    rewrite ^/forums/ /forums/index.php last;
    }

    if (!-e $request_filename) {
    rewrite ^.+/?(/wp-.*) $1 last;
    rewrite ^.+/?(/.*\.php)$ $1 last;
    rewrite ^(.+)$ /index.php?q=$1 last;
    }

    error_page 404 = /index.php?q=$uri;

    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/bandpress.org$fastcgi_script_name;
    include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root concurs with nginx's one
    #
    location ~ /\.ht {
    deny all;
    }
    }

  2. milordk
    Member
    Posted 13 years ago #

    A great example for beginners! for themselves drew on wp super cache;)
    Thank you!

  3. amanzi
    Member
    Posted 13 years ago #

    Thanks for posting this. I managed to get it working with just a few tweaks.

  4. slevy
    Member
    Posted 13 years ago #

    Thanks for posting - can you clarifywhat you are doing with your 301 redirects?

About this Topic