# Problem with try files: =404 results in php files being downloaded instead of parsed by php

**URL:** <https://www.ruby-forum.com/t/problem-with-try-files-404-results-in-php-files-being-downloaded-instead-of-parsed-by-php/220909>\
**Category:** NGINX\
**Created:** [June 25, 2012, 12:24am UTC](https://www.ruby-forum.com/t/problem-with-try-files-404-results-in-php-files-being-downloaded-instead-of-parsed-by-php/220909 "2012-06-25T00:24:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 25, 2012, 12:24am UTC](https://www.ruby-forum.com/t/problem-with-try-files-404-results-in-php-files-being-downloaded-instead-of-parsed-by-php/220909/1 "2012-06-25T00:24:41Z")

</div>

Hello,

I tried changing my template configuration so that it would show “404  
not found” instead of “No input file specified.” but to my surprise,  
try\_files did something completely unpredictable and now I’m stuck with  
“No input file specified.”. To be exact I tried changin this:

> try\_files “$uri” “$uri/” “/index.php”;  
> into this:  
> try\_files “$uri” “$uri/” “/index.php” =404;  
> which then resulted in nginx sending the php file as  
> application-octet-stream, instead of parsing it through the fastcgi  
> handler. How do I do the above right, if not with the try\_files syntax?

My configurations:  
/etc/nginx/nginx.conf - [http://files.realitybends.de/nginx.conf](http://files.realitybends.de/nginx.conf)  
/etc/nginx/mime.types - [http://files.realitybends.de/mime.types](http://files.realitybends.de/mime.types)  
/etc/nginx/conf.d/default.conf -  
[http://files.realitybends.de/conf.d/default.conf](http://files.realitybends.de/conf.d/default.conf)  
/etc/nginx/conf.d/mime.types -  
[http://files.realitybends.de/conf.d/mime.types](http://files.realitybends.de/conf.d/mime.types)  
/etc/nginx/inc.d/global.conf -  
[http://files.realitybends.de/inc.d/global.conf](http://files.realitybends.de/inc.d/global.conf)  
/etc/nginx/inc.d/php.conf - [http://files.realitybends.de/inc.d/php.conf](http://files.realitybends.de/inc.d/php.conf)  
/etc/nginx/sites-available/realitybends.de -  
[http://files.realitybends.de/sites-available/realitybends.de](http://files.realitybends.de/sites-available/realitybends.de)  
The corresponding line is in /etc/nginx/inc.d/global.conf:

> Line 21: try\_files “$uri” “$uri/” “/index.php”;

Thanks in advance,  
Xaymar

Posted at Nginx Forum:

> **[Problem with try\_files: =404 results in php files being downloaded instead of...](https://forum.nginx.org/read.php?2,227833,227833#msg-227833)**
>
> Hello, I tried changing my template configuration so that it would show "404 not found" instead of "No input file specified." but to my surprise, try\_files did something completely unpredictable and now I'm stuck with "No...

---

<div class="post-metadata">

**Author:** ![Xaymar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/e36b37/32.png) [@Xaymar](https://www.ruby-forum.com/u/Xaymar)\
**Post date:** [June 25, 2012, 12:22pm UTC](https://www.ruby-forum.com/t/problem-with-try-files-404-results-in-php-files-being-downloaded-instead-of-parsed-by-php/220909/2 "2012-06-25T12:22:10Z")

</div>

Hello!

On Sun, Jun 24, 2012 at 06:24:01PM -0400, Xaymar wrote:

> application-octet-stream, instead of parsing it through the fastcgi  
> handler.

You’ve asked nginx to return /index.php as static if $uri isn’t  
found, and it does so. No surprise here.

> How do I do the above right, if not with the try\_files syntax?

Add “try\_files $uri =404;” to your “location ~ .php” instead.

[…]

Maxim D.
