# AddHandler application/x-httpd-php .htm in nginx?

**URL:** <https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784>\
**Category:** NGINX\
**Created:** [March 26, 2010, 12:48am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784 "2010-03-26T00:48:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [March 26, 2010, 12:48am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/1 "2010-03-26T00:48:02Z")

</div>

That command in apache htaccess allows to read htm files as php,so then  
you can load php file with extension htm.How do i enable this on nginx?

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [March 26, 2010, 1:06am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/2 "2010-03-26T01:06:43Z")

</div>

On Fri, Mar 26, 2010 at 6:48 AM, Luka H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx?

location ~ .htm$ {  
fastcgi\_pass …  
…  
}

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [March 26, 2010, 11:10am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/3 "2010-03-26T11:10:41Z")

</div>

Edho P Arief wrote:

> On Fri, Mar 26, 2010 at 6:48 AM, Luka H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ## That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx?
> 
> location ~ .htm$ {  
> fastcgi\_pass …  
> …  
> }
> 
> –  
> O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

Forgot to say how i tried following:  
location ~ .htm$ {  
root /location;  
fastcgi\_pass 127.0.0.1:9000;

```
        fastcgi_param SCRIPT_FILENAME 

```

/location$fastcgi\_script\_name;  
include fastcgi\_params;  
}  
It didn’t work,it still read php file as html file.On the other hand,i  
bet it would work if i would pick some misc extension like php2.

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 1:01am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/4 "2010-08-18T01:01:37Z")

</div>

On Fri, 2010-03-26 at 11:10 +0100, Luka H. wrote:

> > }  
> > /location$fastcgi\_script\_name;  
> > include fastcgi\_params;  
> > }  
> > It didn’t work,it still read php file as html file.On the other hand,i  
> > bet it would work if i would pick some misc extension like php2.

This _will_ work. The extension is irrelevant to Nginx. Perhaps you  
should post your entire config. Also, be 100% certain you are not  
encountering browser caching (this catches me out now and again).

Cliff

–

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 12:27am UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/5 "2010-08-18T00:27:41Z")

</div>

Do not have a solution. I have the same problem as well.

Posted at Nginx Forum:

> **[Re: AddHandler application/x-httpd-php .htm in nginx?](https://forum.nginx.org/read.php?2,67909,120819#msg-120819)**
>
> That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx? -- Posted via http://www.ruby-forum.com/. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing...

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/6 "2010-08-18T19:32:12Z")

</div>

my nginx.conf

```auto
#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local]
"$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log logs/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    gzip on;
    gzip_min_length 10240;
    gzip_buffers 64k;
    gzip_types application/x-javascript text/css text/xml
text/plain;

    server {
        listen 80;
        server_name localhost;

        #charset koi8-r;

        #access_log logs/host.access.log main;

        location / {
            root html;
            index index.html index.htm;

        }

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        # proxy_pass http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
        #
        location ~ \.php$ {
            root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        # deny all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based
configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

    # HTTPS server
    #
    #server {
    # listen 443;
    # server_name localhost;

    # ssl on;
    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_timeout 5m;

    # ssl_protocols SSLv2 SSLv3 TLSv1;
    # ssl_ciphers
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

}
```

Posted at Nginx Forum:

> **[Re: AddHandler application/x-httpd-php .htm in nginx?](https://forum.nginx.org/read.php?2,67909,121039#msg-121039)**
>
> That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx? -- Posted via http://www.ruby-forum.com/. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing...

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 9:27pm UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/7 "2010-08-18T21:27:32Z")

</div>

This config does not have any

location ~ .htm$ { }

Please post the actual, real config you are using. Trying to debug a  
phony config is a waste of time.

Cliff

On Wed, 2010-08-18 at 13:31 -0400, codetr wrote:

> ```
> #log_format main '$remote_addr - $remote_user [$time_local]
> keepalive_timeout 65;
> server_name localhost;
> 
> #
> fastcgi_index index.php;
> 
> # root html;
> 
> ```
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 10:36pm UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/8 "2010-08-18T22:36:02Z")

</div>

Yes. worked with this code. Long live the nginx

```auto
location ~ \.htm$ {
      root html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.htm;
            include fastcgi.conf;
  }
```

Posted at Nginx Forum:

> **[Re: AddHandler application/x-httpd-php .htm in nginx?](https://forum.nginx.org/read.php?2,67909,121087#msg-121087)**
>
> That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx? -- Posted via http://www.ruby-forum.com/. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing...

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [August 18, 2010, 7:27pm UTC](https://www.ruby-forum.com/t/addhandler-application-x-httpd-php-htm-in-nginx/185784/9 "2010-08-18T19:27:31Z")

</div>

location ~ .htm$ {  
root /location;  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_param SCRIPT\_FILENAME  
/location$fastcgi\_script\_name;  
include fastcgi\_params;  
}

Does not exactly how I can not run the sample.  
index.htm inside the include file 1.php

Posted at Nginx Forum:

> **[Re: AddHandler application/x-httpd-php .htm in nginx?](https://forum.nginx.org/read.php?2,67909,121037#msg-121037)**
>
> That command in apache htaccess allows to read htm files as php,so then you can load php file with extension htm.How do i enable this on nginx? -- Posted via http://www.ruby-forum.com/. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ nginx mailing...
