title: FastCGI - Rewrite - Location with Nginx
body: <p>I just switched to nginx but I'm having trouble with my URL-Rewriting</p>
  
  <p>I used</p>
  
  <pre><code>location /id/ {
         rewrite ^/id/(.*) /index.php?id=$1 break;
  }
  </code></pre>
  
  <p>But the php code is not interpreted, worst it's downloaded raw.
  Yet .php files are configured as follow:</p>
  
  <pre><code>    location ~ \.php$ {
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  /var/www/my_app$fastcgi_script_name;
              include /etc/nginx/fastcgi_params;
      }
  </code></pre>
  
  <p>What is wrong with my vhost ?</p>
  
  <p>EDIT: Here is the entire vhost 
  server {</p>
  
  <pre><code>    listen   80; ## listen for ipv4
      server_name  viditx.com www.viditx.com; ## change this to your own domain name
  
     # I find it really useful for each domain &amp; subdomain to have
     # its own error and access log
      error_log /var/log/nginx/viditx.com.error.log;
      access_log  /var/log/nginx/viditx.com.access.log;
  root /var/www/viditx;   
  
  location / {
          # Change this to the folder where you want to store your website
          index  index.html index.htm index.php;
  }
  location /phpmyadmin {
             root /usr/share/;
             index index.php index.html index.htm;
             location ~ ^/phpmyadmin/(.+\.php)$ {
                     try_files $uri =404;
                     root /usr/share/;
                     fastcgi_pass 127.0.0.1:9000;
                     fastcgi_index index.php;
                     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                     include /etc/nginx/fastcgi_params;
             }
             location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                     root /usr/share/;
             }
      }
      location /phpMyAdmin {
             rewrite ^/* /phpmyadmin last;
      }
  
  
      # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504  /50x.html;
  
      location = /50x.html {
              root   /var/www/nginx-default;
      }
  
      location ~ \.php$ {
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              # again, change the directory here to your website's root directory
              # make sure to leave $fastcgi_script_name; on the end!
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include /etc/nginx/fastcgi_params;
      }
  </code></pre>
  
  <p>}</p>