title: Nginx is dowloading the rewrite file
body: <p>I have tried the offered solutions:<br />
  <a href="https://stackoverflow.com/questions/15420018/nginx-rewrite-triggers-download">Nginx rewrite triggers download</a><br />
  <a href="https://stackoverflow.com/questions/15714706/nginx-rewrite-to-php-file-file-is-being-downloaded">nginx rewrite to php file - File is being downloaded</a></p>
  <p>but to no avail.</p>
  <p>when I click on the link to <code>/contact</code> it just downloads my redirected file.</p>
  <p>my config:</p>
  <pre><code>    rewrite  ^/test$     /index.php last;
      rewrite  ^/contact$  /index.php last;
  
      location ~ \.php$ {
          try_files      $uri = 404; 
          fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
          fastcgi_index  index.php;
          include        fastcgi.conf;
      }
  
      location / {
          index index.php index.html index.htm;
      }
  </code></pre>
  <p>when I visit <code>/test</code> it redirects successfully, but when I try and access <code>/contact</code> it fails. Accessing php directly works as expected.<br />
  I have also tried with the rewrites in the  <code>location /</code> block, but I get the same error.</p>
  <h2>edit</h2>
  <p>I have taken out all my redirect rules, and it still downloads my index file.</p>
  <p>nginx.conf</p>
  <pre><code>#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 {
      passenger_root /usr/lib/passenger/;
      passenger_ruby /usr/local/rvm/wrappers/ruby-head/ruby;
  
      include       mime.types;
      default_type  application/octet-stream;
  
      sendfile        on;
      keepalive_timeout  65;
      server_names_hash_bucket_size 64;
  
      #gzip  on;
  
      include /opt/nginx/conf/enabled/*.conf;
  }
  </code></pre>
  <p>/opt/nging/conf/enabled/root.conf</p>
  <pre><code>server { 
      listen       80;
      server_name  example.com;
      root   /srv/http/public;
  
      location ~ \.php$ {
          try_files      $uri = 404; 
          fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
          fastcgi_index  index.php;
          include        fastcgi.conf;
      }
  
      location / {
          index index.php index.html index.htm;
      }
  
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   html;
      }
  }
  </code></pre>