Nginx rewrite for wordpress MU problem


#1

I’ve seen on wordpress website for the rewrite rule for nginx

But when I access the blog, it always show me http://blog.mysite.com/*
index.php*

How can I rewrite the index.php so that i just have
http://blog.mysite.com ?

Thank’s in advance


#2

On Thu, Oct 23, 2008 at 12:34 AM, Dave C. removed_email_address@domain.invalid wrote:

this location block stuff is not needed:

  • location / {
    index index.php;
  • }

note that these can be hardcoded into fastcgi.conf and even placed on
a global level


#3

Try this

server {

...

location / {
  index index.php;
}

location ~ \.php$ {
   include fastcgi.conf;

   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME /path/to/root$fastcgi_script_name;
   fastcgi_pass   unix:/tmp/php-fastcgi.sock;
}

}

Cheers

Dave


#4

to clarify:

i meant global server {} level

and so you don’t have to hardcode it

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


#5

Cool - thanks, I didn’t know that.


#6

On Thu, Oct 23, 2008 at 07:15:10PM +1100, Dave C. wrote:

Cool - thanks, I didn’t know that.

Yes, you may omit location / {}, but usually I set it up.


#7

Hi all,

Just wondering, I’m trying to setup Wordpress MU with nginx. Have search
both wordpress, google and this forum for solution, but unable to find.

I’m having problem showing the post using permalink, it gives 404 error.

I installed Wordpress MU on a sub-folder on
/nginx/html/domain.com/blogs.

  • Pages are working just fine
  • Site Admin works fine

My nginx.conf is as follows:

server {
listen 80;
server_name domain.com *.domain.com;

root /nginx/html/domain.com;
index index.php index.html index.htm;

rewrite ^./files/(.) /wp-content/blogs.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.) $1 last;
rewrite ^.+?(/.
.php)$ $1 last;
rewrite ^ /index.php last;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param
SCRIPT_FILENAME/nginx/html/domain.com$fastcgi_script_name;
include fastcgi_params;
}
}

Can anyone tell me what I missed? Thank you in advance.


#8

On Thu, Mar 5, 2009 at 9:58 PM, Endra P. removed_email_address@domain.invalid
wrote:

  • Pages are working just fine

   fastcgi_param
SCRIPT_FILENAME/nginx/html/domain.com$fastcgi_script_name;
   include fastcgi_params;
 }
}

Can anyone tell me what I missed? Thank you in advance.

Posted via http://www.ruby-forum.com/.

rewrite rule for the folder

location ^~ /blogs/ {
rewrite ^./files/(.) /blogs/wp-content/blogs.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.) /blogs/$1 last;
rewrite ^.+?(/.
.php)$ /blogs/$1 last;
rewrite ^ index.php last;
}
}

*this is just example.
*WP-MU is basically rewrite hell. I personally won’t install it
together with another webapp that requires rewrites.