Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: nginx re-write rules

I belive I found the bug :) running domain/wp-signup.php worked but domain/members/USER/blogs/create-a-blog didn’t. I suspected the error_page 404 = /index.php?q=$uri; directive and changing that fixed the problem. I changed it to:

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

The comple working DOMAIN.conf is:

server
{

listen 80;
server_name DOMAIN.COM *.DOMAIN.COM;

access_log /usr/local/nginx/logs/DOMAIN.COM.access.log;
error_log /usr/local/nginx/logs/DOMAIN.COM.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/web/DOMAIN.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 /
{
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
root /home/web/DOMAIN.COM/www;
index index.php;
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}

#send php requests to fast cgi

location ~ .php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/web/DOMAIN.COM/www$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}

}

Skip to toolbar