Welcome! Log In Create A New Profile

Advanced

Re: Requests ending with / (slash) are returning 404

April 07, 2010 06:28AM
Thanks Igor, it makes sense now. Thanks for the link it was helpful too.

Cheers

Leo

2010/4/7 Igor Sysoev <igor@sysoev.ru>:
> On Wed, Apr 07, 2010 at 07:26:31PM +1000, Leonardo Crespo wrote:
>
>> I can't make sense of those 2.
>>
>> >  try_files $uri.php ${uri}index.php =404;
>>
>> This means: if  the uri is xxx, try to serve xxx.php. If you can't,
>> try serving xxxindex.php. If you can't still, return 404.
>
> Yes. Note, that ${uri}index.php is for "xxx/", i.e. "xxx/index.php".
>
>> >  try_files $uri.php $uri/ =404;
>>
>> This means: if the uri is xxx, try to serve xxx.php.  If you can't,
>> try serving xxx/ . If you can't still, return 404.
>>
>> Correct? They both work fine, what is the difference between them?
>
> The trailing slash in "$uri/" tests that $uri, i.e., "xxx" or "xxx/"
> is a directory. Further directory handling depends on directives.
>
> If you use
>
>    location / {
>        try_file  ... $uri/  ...
>        index     index.php;
>    }
>
> then nginx will test index file for request, look
> http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration
>
> If you use
>
>    location / {
>        try_file  ... $uri/  ...
>        fastcgi_pass      ...
>        fastcgi_index     index.php;
>    }
>
> then nginx will add index.php to $uri in $fastcgi_script_name
> for request with trailing slash.
>
>> On Wed, Apr 7, 2010 at 7:16 PM, Edho P Arief <edhoprima@gmail.com> wrote:
>> > On Wed, Apr 7, 2010 at 4:10 PM, Leonardo Crespo <leo@leocrespo.com> wrote:
>> >> Hi Edho, thanks.
>> >>
>> >> Igor mentioned i should keep this to avoid serving php as static files.
>> >>
>> >> location ~ \.php$
>> >>        {
>> >>                fastcgi_pass 127.0.0.1:9000;
>> >>                fastcgi_intercept_errors on;
>> >>                fastcgi_index index.php;
>> >>                include /usr/local/nginx/conf/fastcgi_params;
>> >>                fastcgi_param SCRIPT_FILENAME
>> >> /home/public_html/boysdownunder.com.au/public/$fastcgi_script_name;
>> >>        }
>> >>
>> >> Will it conflict with this?
>> >>
>> >>> location ~ \.php$ {
>> >>>  return 404;
>> >>> }
>> >>
>> >
>> > as all php requests (usin are passed to @php block (or / block in
>> > Igor's example), there shouldn't be any problem.
>> >
>> > And in my example it should be
>> >
>> >  try_files $uri.php ${uri}index.php =404;
>> >
>> > instead of
>> >
>> >  try_files $uri.php $uri/ =404;
>> >
>> >
>> > --
>> > O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
>> >
>> > _______________________________________________
>> > nginx mailing list
>> > nginx@nginx.org
>> > http://nginx.org/mailman/listinfo/nginx
>> >
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://nginx.org/mailman/listinfo/nginx
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

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

Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 04:28AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 04:44AM

Re: Requests ending with / (slash) are returning 404

edogawaconan April 07, 2010 04:54AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 05:02AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 05:02AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 05:06AM

Re: Requests ending with / (slash) are returning 404

edogawaconan April 07, 2010 05:08AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 05:14AM

Re: Requests ending with / (slash) are returning 404

edogawaconan April 07, 2010 05:20AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 05:30AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 05:34AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 05:50AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 05:48AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 06:28AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 06:44AM

Re: Requests ending with / (slash) are returning 404

edogawaconan April 07, 2010 06:50AM

Re: Requests ending with / (slash) are returning 404

leocrespo April 07, 2010 07:10AM

Re: Requests ending with / (slash) are returning 404

Igor Sysoev April 07, 2010 05:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 93
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