The MU forums have moved to WordPress.org

wordpress rewrites on nginx (35 posts)

  1. honewatson
    Member
    Posted 9 years ago #

    This is better for a basic set up which does not include supercache :

    server {
    listen       80;
    server_name muinstall.com *.muinstall.com;
    
    access_log  /usr/local/nginx/logs/mu.access.log;
    
    location ~* ^.+\.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$
    	{
    		root /home/mudirectory/public_html;
    		rewrite ^/files(/.*)$ /wp-content/blogs.php?file=$1 last;
    		expires 10d;
    		break;
    	}
    
    location / {
                	root   /home/mudirectory/public_html;
                	index index.php;
    	    	error_page       404 = /index.php?q=$uri;
    }
    
    location ~ \.php$ {
    	fastcgi_pass   127.0.0.1:9000;
    	fastcgi_index  index.php;
    	fastcgi_param  SCRIPT_FILENAME /home/mastersvn/mutrunk$fastcgi_script_name;
    	include        /usr/local/nginx/conf/fastcgi_params;
    }
    
    }
  2. jhh2006
    Member
    Posted 9 years ago #

    Thanks. Interestingly I got the wildcard working without the *. that you added at the top. I will try your version today adn report back. Much obliged.

  3. honewatson
    Member
    Posted 9 years ago #

    It will work without the wildcard if your mu installation is also the default nginx server conf.

  4. jhh2006
    Member
    Posted 9 years ago #

    Yup this works.

    server
    {
    
    	listen			80;
    	server_name		MYSITE.COM	*.MYSITE.COM;
    
    	access_log 		/home/public_html/MYSITE.COM/log/access.log;
    	error_log 		/home/public_html/MYSITE.COM/log/error.log;
    
    # rewrite rule for files
    
    	location	~*	^.+\.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$
    	{
    		root		/home/public_html/MYSITE.COM/www;
    		rewrite		^/files(/.*)$	/wp-content/blogs.php?file=$1	last;
    		expires		10d;
    		break;
    	}
    
    # rewrite rule for sitemap under the lines that handles upload files
    
    	rewrite ^(.*/)?sitemap.xml wp-content/sitemap.php;
    
    # rewrite errors
    
    	location	/
    	{
    		root		/home/public_html/MYSITE.COM/www;
    		index		index.php;
    		error_page	404	= /index.php?q=$uri;
    	}
    
    #send php requests to fast cgi
    
    	location	~	\.php$
    	{
    		fastcgi_pass		127.0.0.1:9000;
    		fastcgi_index		index.php;
    		fastcgi_param		SCRIPT_FILENAME		/home/public_html/MYSITE.COM/www$fastcgi_script_name;
    		include				/usr/local/nginx/conf/fastcgi_params;
    	}
    
    }

    Now to figure out supercache!

  5. PerS
    Member
    Posted 9 years ago #

    Just a FYI. I had to change error_page 404 = /index.php?q=$uri; to get it to work with BuddyPress. I changed it to:

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

    more at: http://buddypress.org/forums/topic.php?id=1278#post-8539

About this Topic