# Rewrite rule to parse .html to .php?

**URL:** <https://www.ruby-forum.com/t/rewrite-rule-to-parse-html-to-php/154326>\
**Category:** NGINX\
**Created:** [November 27, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/rewrite-rule-to-parse-html-to-php/154326 "2008-11-27T18:19:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 27, 2008, 6:19pm UTC](https://www.ruby-forum.com/t/rewrite-rule-to-parse-html-to-php/154326/1 "2008-11-27T18:19:08Z")

</div>

Without editing:

```
            location ~ \.php$ {
                    include conf/fastcgi_params;
                    fastcgi_pass unix:/home/nginx/phpcgi/USERNAME;
                    fastcgi_index index.php;
            }

```

Is there a way to add in nginx to send any \*.html requests to as \*.php  
to  
Nginx?

Without having to add another directive like:

```
            location ~ \.html$ {
                    include conf/fastcgi_params;
                    fastcgi_pass unix:/home/nginx/phpcgi/USERNAME;
                    fastcgi_index index.php;
            }

```

Just to do what I want.

I am developing a backend for Nginx for in a shared-hosting environment,  
just I don’t want to give customers access to edit this part of the  
config,  
so looking for a rewrite rule if possible to send \*.html to \*.php , or  
anything in that concept.

Thanks

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 27, 2008, 10:59pm UTC](https://www.ruby-forum.com/t/rewrite-rule-to-parse-html-to-php/154326/2 "2008-11-27T22:59:59Z")

</div>

The rewrite rule is build with regular expression, so you can do this:  
location ~ .(php|html?)$ {  
include conf/fastcgi\_params;  
fastcgi\_pass unix:/home/nginx/phpcgi/USERNAME;  
fastcgi\_index index.php index.htm index.html;  
}

Marcos N.  
+55 44 3263-8132  
+55 44 9918-8488

2008/11/27 Joe S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
