Wordpress (single blog installation) and nginx

Igor Sysoev is at rambler-co.ru
Thu Dec 13 11:56:53 MSK 2007


On Thu, Dec 13, 2007 at 09:06:05AM +0100, Abdul-Rahman Advany wrote:

> Hi guys,
> 
> I am running php with nginx, with fastcgi. But instead of heaving my urls
> like www.myblog.com/index.php/bla/bla I would like
> www.myblog.com/bla/bla<http://www.myblog.com/bla/bla.>
> 
> With the setup at the end of the mail, it redirect if a file can't be found
> to index.php, but I get the content of index.php back. (So if I go to
> www.myblog.com/bla/bla).
> 
> But I also have other requests that should not be rewritten (directories and
> files in the root directory). Is this possible? to redirect only if
> www.myblog.com/bla/bla doesn't exist to a normal request to the root
> directory and send that to the fastcgi process?

How does wordpress find what URI you request ?
I know that wordpress may use REQUEST_URI (it should already set
in /etc/nginx/fastcgi.conf):

fastcgi_param  REQUEST_URI        $request_uri;

The second way (I do not know whether Wordpress use it) is PATH_INFO:

      location / {
           root /var/www/blog;
           error_page  404 /index.php;
      }

      location ~ \.php$ {
           include        /etc/nginx/fastcgi.conf;
           fastcgi_pass 127.0.0.1:8888;
           fastcgi_param  PATH_INFO        $request_uri;
           fastcgi_param  SCRIPT_FILENAME  /var/www/blog/$fastcgi_script_name;
      }

      location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
           root /var/www/blog;
      }


> I really love nginx, and thanks to this mailinglist I didn't need much help.
> But most rewrite rules are written wordpress MU (multiuser) and not
> wordpress redux. I just need to to rewrite all request that do not exists to
> index.php and pass this to fastcgi.
> 
> I did get this working one time.. but I can't figure out how I did it :S
> 
> server {
>         listen      80;  # Replace this IP and port with the right
> ones for your requirements
>         server_name  www.myblog.com
> 
>         #charset koi8-r;
> 
>         #access_log  logs/host.access.log
> 
>         location ~*
> ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$
> {
>           root /var/www/blog;
>         }
> 
>         error_page  404 /index.php;
> 
>         location ~ \.php$ {
>           include        /etc/nginx/fastcgi.conf;
>           fastcgi_pass
> 127.0.0.1:8888;
>           fastcgi_index  index.php;
>           fastcgi_param  SCRIPT_FILENAME  /var/www/blog/$fastcgi_script_name;
>         }
> 
>         # deny access to .htaccess files, if Apache's document root
>         # concurs with nginx's one
>         #
>         #location ~ /\.ht {
>         #    deny  all;
>         #}
> 
>      }
> 
> 
> 
> -- 
> Abdul-Rahman Advany
> 
> IM: abdulrahman at advany.com

-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list