Question on rewriting ...

Rakhesh Sasidharan rakhesh at rakhesh.com
Wed Sep 5 15:56:42 MSD 2007


Igor Sysoev wrote:

> 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;
>>>         ...
>>>
>>

>> --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 ?

Not sure what you meant by the question. I have a couple of FastCGI 
processes running for handling PHP requests. That's what you meant? So I 
have a location directive for matching php files and passing on 
accordingly ...

Regards,

 				- Rakhesh
                                 http://rakhesh.net/





More information about the nginx mailing list