wordpress rewrite nginx

Anonymous Coward magasesti at gmail.com
Wed Feb 14 16:56:55 MSK 2007


Worked like a charm...
Even tho' Chris Wells (big thanks again) suggested earlier on irc

                if (!-e $request_filename) {
                rewrite ^(.*)(/wp-content/themes/.*) $2 last;
                rewrite ^/.*$ /index.php last;
                }

which worked too but i didnt managed to reply to list to tell you as i was
testing more stuff on it..
As i was testing with ab2 -n 1000 -c 100
http://sub.domain.tld/blog1/files/2007/02/40kb.jpg getting only ~230req/sec
i noticed that php-cgi got hit everytime and i don't understand why it
happens that when i access a static file which should be served directly
after rewrite by nginx
if i do ab2 -n 1000 -c 100
http://sub.domain.tld/wp-content/blogs.dir/4/files/2007/02/40kb.jpg (which
is the same file only without rewrite) i get ~400req/sec

(should i start another "thread" with nginx and maybe some WP related
questions or i can continue here?)

Thank you again for the great/fast help.

On 2/14/07, Igor Sysoev <is at rambler-co.ru> wrote:
>
> On Wed, Feb 14, 2007 at 04:21:49PM +0300, Igor Sysoev wrote:
> > On Wed, Feb 14, 2007 at 12:09:05PM +0200, Anonymous Coward wrote:
> >
> > Let's start from the scratch:
> >
> > 1) set the root at server level,
> > 2) and move all if/rewrite rules to server level, then they will run
> >    only once:
> >
> >     server {
> >         ...
> >
> >         root    /var/www/localhost/htdocs/sub.domain.tld;
> >
> >         #uploaded files
> >         rewrite  ^(.*)?/?files/(.*) /wp-content/blogs.php?file=$2;
>
> -         rewrite  ^(.*)?/?files/(.*) /wp-content/blogs.php?file=$2;
> +         rewrite  ^.*/files/(.*) /wp-content/blogs.php?file=$1;
>
> >
> >         if (!-e $request_filename) {
> >             rewrite  ^.+?(/wp-.*)     $2          last;
> >             rewrite  ^.+?(/.*\.php)$  $2          last;
>
> -             rewrite  ^.+?(/wp-.*)     $2          last;
> -             rewrite  ^.+?(/.*\.php)$  $2          last;
> +             rewrite  ^.+?(/wp-.*)     $1          last;
> +             rewrite  ^.+?(/.*\.php)$  $1          last;
>
> >             rewrite  ^                /index.php  last;
> >         }
> >
> >         ...
> >     }
> >
> >
> > The "^([_0-9a-zA-Z-]+)?(/wp-.*)" does not match
> "/test130/wp-content/...".
> >
> >
> > > I tried that too, same result...
> > > I also looked in access.log and i noticed that i was getting 404 on
> these
> > > files
> > >
> > > /test130/wp-content/themes/default/style.css
> > > /test130/wp-content/themes/default/images/kubrickbg.jpg
> > >
> > > On website i was trying to access sub.domain.tld/test130/   (which is
> a blog
> > > in Wordpress Mu) and on the server the files were in
> > >
> > > $documentroot/wp-content/themes/home/images/kubrickbg.jpg
> > > $documentroot/wp-content/themes/default/images/kubrickbg.jpg
> > >
> > > $documentroot/wp-content/themes/home/style.css
> > > $documentroot/wp-content/themes/default/style.css
> > > $documentroot/wp-content/themes/classic/style.css
> > >
> > > Maybe this will clear something...
> > >
> > > It's seems that "^([_0-9a-zA-Z-]+)?(/wp-.*)" are static files, so
> "break"
> > > >stops rewrite cycle. The "last" continues rewrite cycle and request
> will
> > > >go to "location ~ .php$".
> >
> >
> > --
> > Igor Sysoev
> > http://sysoev.ru/en/
> >
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20070214/3c40f358/attachment.html>


More information about the nginx mailing list