nginx + wordpress rewrite question

Edho P Arief edhoprima at gmail.com
Tue Feb 9 10:34:19 MSK 2010


On Tue, Feb 9, 2010 at 2:21 PM, Edho P Arief <edhoprima at gmail.com> wrote:
> wordpress is pretty smart in handling rewrites
>
> here's example for wordpress installation in a root of a domain:
>
> server {
>  listen 80;
>  server_name my.blog.com;
>  location ~ ^/.*\.php$ {
>    root /srv/http/wordpress;
>    fastcgi_pass 127.0.0.1:9100;
>    fastcgi_index index.php;
>    fastcgi_param SCRIPT_FILENAME $request_filename;
>    include fastcgi_params;
>  }
>  location / {
>    index index.php;
>    root /srv/http/wordpress;
>    try_files $uri /index.php;
>    expires max;
>  }
> }
>
>
>

inside a directory, it'd be either:

server {
 listen 80;
 server_name my.blog.com;
 location ~ ^/blog/.*\.php$ {
   root /srv/http/wordpress;
   fastcgi_pass 127.0.0.1:9100;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME $request_filename;
   include fastcgi_params;
 }
 location /blog/ {
   index index.php;
   root /srv/http/wordpress;
   try_files $uri /index.php;
   expires max;
 }
  location = /blog {
    rewrite ^ /index.php;
  }
}

and then create symlink /srv/http/wordpress/blog pointing to
/srv/http/wordpress;

or

server {
  listen 80;
  server_name my.blog.com;
  location ~ ^/blog/(.*\.php)$ {
    alias /srv/http/wordpress/$1;
    fastcgi_pass 127.0.0.1:9100;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    include fastcgi_params;
  }
  location /blog/ {
    index index.php;
    alias /srv/http/wordpress/;
    error_page 404 = /index.php;
    expires max;
  }
  location = /blog {
    rewrite ^ /blog/index.php;
  }
}


-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the nginx mailing list