Welcome! Log In Create A New Profile

Advanced

Re: another rewrite/try files issue

May 23, 2011 04:04PM
On Mon, May 23, 2011 at 12:20:55AM +0300, Stelianos G. Sfakianakis wrote:
> Hello,
>
> I am having the following problem:
>
> - I want to have a "virtual" url e.g. "/myapp" to have a totally
> different document root e.g. "/home/stelios/myapp" (instead of the
> default '/var/www')
> - locations of the type "/myapp/css/print.css" should respond with
> the specific file at the "/home/stelios/myapp" root (i.e. with
> "/home/stelios/myapp/css/print.css"
> - if the the file requested does not exist, then the "index.php"
> should be called via FastCGI with args "?u=$uri" (e.g.
> "/myapp/users/12" should be rewritten to
> "/home/stelios/myapp/index.php?u=users/12")
>
> I have tried the following:
>
> location ~ /myapp/(.*) {
> root /home/stelios/myapp;
> try_files /$1 /$1/ /index.php?u=$1;
> }
> # and the "default" PHP/FastCGI
> location ~ \.php$ {
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> include fastcgi_params;
> }
>
>
> but it seems that it doesn't work for the non files. In particular it
> seems that after the internal redirect to index.php, the root is
> overwritten and instead of calling my /home/stelios/myapp/index.php
> the one at the default root ("/var/www/index.php") is beeing called.
>
> Do you know what's wrong? And possibl another way to achieve what I want?

location /myapp/css/ {
root /home/stelios;
}

location /myapp/ {
root /home/stelios;
try_files $uri $uri/ @php;
}

location @php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /home/stelios/myapp/index.php;
fastcgi_param QUERY_STRING u=$uri;
include fastcgi_params0;
}

fastcgi_params0 is a copy of fastcgi_params without QUERY_STRING parameter.


--
Igor Sysoev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

another rewrite/try files issue

Stelianos G. Sfakianakis May 22, 2011 05:22PM

Re: another rewrite/try files issue

brianmercer May 22, 2011 06:06PM

Re: another rewrite/try files issue

Stelios Sfakianakis May 23, 2011 02:54AM

Re: another rewrite/try files issue

brianmercer May 23, 2011 02:02PM

Re: another rewrite/try files issue

Stelianos G. Sfakianakis May 23, 2011 03:32PM

Re: another rewrite/try files issue

António P. P. Almeida May 23, 2011 04:26PM

Re: another rewrite/try files issue

Igor Sysoev May 23, 2011 04:04PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 255
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready