Rewrite except one directory

Hello,

I’m using the following rewrite options

{
    try_files   $uri @pico;
}

location @pico
{
    rewrite     ^(.*)$ /index.php;
}

So I would like to disable the rewrite for one subfolder. I have some
PHP scripts with should not use the
rewrite call e.g. http://myserver/scripts/script1.php. All scripts with
are in the /script location should not
use the rewrite to the index.

How can I do this?

Thanks

Phil

On Sun, Feb 16, 2014 at 07:58:33AM +0100, Philipp Kraus wrote:

Hi there,

So I would like to disable the rewrite for one subfolder. I have some PHP
scripts with should not use the
rewrite call e.g. http://myserver/scripts/script1.php. All scripts with are in
the /script location should not
use the rewrite to the index.

How can I do this?

The same way any prefix-based nginx config would be done, unless there’s
a reason it fails?

==
location ^~ /scripts/ {

do your /scripts/ stuff

}
location / {

do everything else

}

f

Francis D. [email protected]

Hi

thanks for your answer, seems to be working

==
location ^~ /scripts/ {

do your /scripts/ stuff

}
location / {

do everything else

}

I have defined my script location with:

location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    include /etc/nginx/fastcgi_params;
}

location ^~/scripts
{
    alias /home/www/content/scripts;
}

but in my alias path there are stored PHP scripts and at the moment
I get a download of the script but the script is not pushed to the
fast-cgi
process. How can I enabled in the script location the PHP CGI for *.php
files?

Thanks

Phil

Hi,

Am 16.02.2014 um 21:38 schrieb Jim O. [email protected]:

With a nested location, or, if all the contents of /home/www/content/scripts are
PHP scripts, use a fastcgi_pass.

Remember, all requests are handed by one location, and one location only.
Writing instructions for how to handle PHP scripts in one location does not tell
nginx how to handle them in other locations.

Thanks, imho my first PHP should be a “global” definition, but I see
this is wrong. I’m using the nested version with

location ^~/scripts.
{
    alias /home/www/content/scripts;
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;
    }
}

so imho all PHP scripts in my script location should be run, but at the
moment I get also a download, the script is not passed to the PHP
fast-cgi process. I call it
with http://myserver/scripts/myscript.php and myscript.php is downloaded

Thanks

Phil

Hello,

On 2/16/14, 2:57 PM, Philipp Kraus wrote:

}
location ^~/scripts
{
alias /home/www/content/scripts;
}

but in my alias path there are stored PHP scripts and at the moment
I get a download of the script but the script is not pushed to the fast-cgi
process. How can I enabled in the script location the PHP CGI for *.php
files?

With a nested location, or, if all the contents of
/home/www/content/scripts are PHP scripts, use a fastcgi_pass.

Remember, all requests are handed by one location, and one location
only. Writing instructions for how to handle PHP scripts in one location
does not tell nginx how to handle them in other locations.

So:

location ^~/scripts {
alias /home/www/content/scripts;
fastcigi_pass 127.0.0.1;
include /etc/nginx/fastcgi_params;
}

Or, if you have content there other than PHP scripts in the alias
location:

location ^~/scripts {
alias /home/www/content/scripts;
location ~.php$ {
fastcigi_pass 127.0.0.1;
include /etc/nginx/fastcgi_params;
}
}


Jim O.

“Never argue with a fool, onlookers may not be able to tell the
difference.” - Mark Twain

On Sun, Feb 16, 2014 at 09:54:47PM +0100, Philipp Kraus wrote:

Am 16.02.2014 um 21:38 schrieb Jim O. [email protected]:

Hi there,

This location…

location ^~/scripts.

does not match this request…

with http://myserver/scripts/myscript.php and myscript.php is downloaded

So depending on the full configuration used, serving the file as a file
may be what nginx was told to do.

f

Francis D. [email protected]