# Browser downloading html files

**URL:** <https://www.ruby-forum.com/t/browser-downloading-html-files/242770>\
**Category:** NGINX\
**Created:** [July 18, 2015, 6:30pm UTC](https://www.ruby-forum.com/t/browser-downloading-html-files/242770 "2015-07-18T18:30:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 18, 2015, 6:30pm UTC](https://www.ruby-forum.com/t/browser-downloading-html-files/242770/1 "2015-07-18T18:30:06Z")

</div>

Hi,  
Haven’t used nginx in few years and trying to get it into production.

i’m having what will probably be a silly misconfiguration to most. I’m  
running nginx  
_nginx_-1.8.0-1.el7.ngx.x86\_64  
CentOS 7  
with PHP-fpm

When I hit every PHP link on this site it generates some html and my  
browser downloads it. I used the winginx .htaccess converter to create  
the  
rewrite rules.

Any direction would be great

Thanks,  
James

Here is my config:

server {

```
listen 80;

server_name www.imagesite.net *.imagesite.net;

root /var/www/imagesite.net/html;

index index.php;

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 /usr/share/nginx/html;

}

# 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_intercept_errors on;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /var/www/

```

[imagesite.net/html$fastcgi\_script\_name](http://imagesite.net/html$fastcgi_script_name);

```
    include fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

location ~ /\.ht {

    deny all;

}

autoindex off;

location / {

  autoindex off;

  rewrite ^/([^/]*)/([^/]*)/([^/]*)\.html$

```

/item.php?parentcategorie=$1&categorie=$2&fx=$3 break;

```
  rewrite ^/([^/]*)/$ /cat.php?parentcategorie=$1 break;

  rewrite ^/([^/]*)/([^/]*)/$

```

/subcat.php?parentcategorie=$1&categorie=$2 break;

```
  rewrite ^/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$

```

/page.php?parentcategorie=$1&categorie=$2&fx=$3&img=$4 break;

```
  try_files $uri $uri/ =404;

  }

```

}
