Question on rewriting ...
Rakhesh Sasidharan
rakhesh at rakhesh.com
Wed Sep 5 12:30:42 MSD 2007
>> 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 ...
Here's the logs when a correct URL http://rakhesh.com/feed/rss is given:
--8<---
2007/09/05 12:27:42 [notice] 50843#0: *38 "^/feed/(rss|rss2|atom|rdf)/?$"
matches "/feed/rss", client: 212.72.24.148, server: rakhesh.com, URL:
"/feed/rss", host: "rakhesh.com"
2007/09/05 12:27:42 [notice] 50843#0: *38 rewritten data: "/", args:
"feed=rss", client: 212.72.24.148, server: rakhesh.com, URL: "/feed/rss",
host: "rakhesh.com"
--8<---
It gets rewritten to / with the proper arguments "feed=rss" passed on!
Any ideas?
Regards,
- Rakhesh
http://rakhesh.net/
More information about the nginx
mailing list