Question on rewriting ...

Igor Sysoev is at rambler-co.ru
Wed Sep 5 14:53:18 MSD 2007


On Wed, Sep 05, 2007 at 12:30:42PM +0400, Rakhesh Sasidharan wrote:

> 
> >>So I modify the config to the following:
> >>
> >>------8<-----------------------
> >>location / {
> >>     root        /net/store/www/data/wordpress;
> >>     index       index.php;
> >>
> >>     if (!-e $request_filename) {
> >>        rewrite ^/log/(.*)?$                    /index.php?q=$1 last;
> >>	rewrite ^/feed/(rss|rss2|atom|rdf)$     /?feed=$1       last;
> >>        rewrite ^/feed/.+$                      /index.php      last;
> >>     }
> >>}
> >>------8<-----------------------
> 
> <snip>
> 
> >>The first two work as required.
> >>
> >>The third one seems to work sort of coz I get my blog page, but with a 404
> >>error message from WordPress! So that leads me to think the URL is not
> >>getting rewritten the way I want -- it is getting rewritten but for some
> >>reason the "/feed/<whatever>" bit too is passed on to index.php. And this
> >>is the cause for the 404 error.
> >>
> >>Any ideas why this is happening the way it is? Strangely enough, when I
> >>modify the /feed/<whatever> rule to redirect to http://rakhesh.com/
> >>instead of just rewrite, things work! So I figure I've got something wrong
> >>in my understanding of these rewrite rules ...
> >
> >Try set
> >error_log   /path/to/log  notice;
> >
> >    location / {
> >         rewrite_log  on;
> >         ...
> >
> 
> Hi!
> 
> I  turned on the rewrite_log and this is what I see for a URL such as 
> http://rakhesh.com/feed/asdaa (an incorrect URL):
> 
> --8<---
> 2007/09/05 12:22:43 [notice] 50842#0: *1 "^/feed/(rss|rss2|atom|rdf)/?$" 
> does not match "/feed/asdaa", client: 212.72.24.148, server: rakhesh.com, 
> URL: "/feed/asdaa", host: "rakhesh.com"
> 2007/09/05 12:22:43 [notice] 50842#0: *1 "^/feed.+$" matches 
> "/feed/asdaa", client: 212.72.24.148, server: rakhesh.com, URL: 
> "/feed/asdaa", host: "rakhesh.com"
> 2007/09/05 12:22:43 [notice] 50842#0: *1 rewritten data: "/index.php", 
> args: "", client: 212.72.24.148, server: rakhesh.com, URL: "/feed/asdaa", 
> host: "rakhesh.com"
> --8<---
> 
> Even though the rewrite seems to happen, the blog sees the "/feed/asdaa" 
> URL. Strange ...

How do you pass request to backend ?


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





More information about the nginx mailing list