# Replacing the php regex with try\_files?

**URL:** <https://www.ruby-forum.com/t/replacing-the-php-regex-with-try-files/200608>\
**Category:** NGINX\
**Created:** [December 17, 2010, 8:10am UTC](https://www.ruby-forum.com/t/replacing-the-php-regex-with-try-files/200608 "2010-12-17T08:10:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 17, 2010, 8:10am UTC](https://www.ruby-forum.com/t/replacing-the-php-regex-with-try-files/200608/1 "2010-12-17T08:10:15Z")

</div>

Hi all,

Right now I use this type of configuration:

```auto
        location / {
                try_files $uri $uri/
/index.php?q=$uri&$args;
        }
        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
        }
```

My goal is to eliminate the regex on php file names:

```auto
        location / {
                try_files $uri $uri/ @php;
        }
        location @php {
                try_files $uri.php /index.php?q=$uri&$args
/404.html;
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
        }
```

I’m not sure if this is the correct way to do it. Any suggestions are  
welcome.

Posted at Nginx Forum:

> **[Replacing the php regex with try\_files?](https://forum.nginx.org/read.php?2,159307,159307#msg-159307)**
>
> Hi all, Right now I use this type of configuration: \[code\] location / { try\_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \\.php$ { fastcgi\_pass 127.0
