Rewrite issue

Igor Sysoev is at rambler-co.ru
Mon Sep 29 22:44:47 MSD 2008


On Mon, Sep 29, 2008 at 12:35:23PM -0500, Clint Priest wrote:

> I've got an odd configuration issue I cannot solve, using this config:
> 
> server {
>    listen             80;
>    access_log        logs/leadgen.access         main;
>    error_log        logs/leadgen.error;
>    root            /opt/leadgen;
>    index            index.php;
>   
>    # If its referencing a resource, check other locations
>    location /res {
>        rewrite ^/res/(.+)$                            
> /code/script.CustomResource.php?File=$1                last;
>    }
>    location / {
>        rewrite ^/Blocked$                             
> /code/Scripts/Blocked.php                            last;
>    }
> 
>    location ~* \.php {
>        include fastcgi;
>    }
> }   
> 
> Going to the following url: /res/xyz.gif properly gets rewritten to 
> /code/script.CustomResource.php?File=xyz.gif and the php processor 
> properly handles the php file.
> 
> But going to this url: /Blocked properly gets rewritten to 
> /code/Scripts/Blocked.php but the php processer never handles the php 
> file, nginx returns the .php source code.

It should work. Could you make debug log ?

Also this location

    location / {
        rewrite ^/Blocked$      /code/Scripts/Blocked.php     last;
    }

is better to divide to

    location / {
    }

    location = /Blocked {
        rewrite ^     /code/Scripts/Blocked.php      last;
    }


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





More information about the nginx mailing list