Rewrite a url on Nginx
- by Ido B
I tried to use this -
    location / {
      root    /path.to.app/;
      index   index.php index.html;
      rewrite                 ^/(.*)$ /check_register.php?key=$1 break;
      fastcgi_pass            127.0.0.1:9000;
      fastcgi_index           index.php;
      fastcgi_param           SCRIPT_FILENAME  /path.to.app/$fastcgi_script_name;
      include                 fastcgi_params;
    }
And its didn't work ,
This is my full config -
    user www-data www-data;
worker_processes  4;
events {
    worker_connections  3072;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log  off;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     off;
    keepalive_timeout  15;
    gzip  on;
    gzip_comp_level 3;
    gzip_proxied any;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location / {
          root    /path.to.app/;
          index   index.php index.html;
          rewrite                 ^/(.*)$ /check_register.php?key=$1 break;
          fastcgi_pass            127.0.0.1:9000;
          fastcgi_index           index.php;
          fastcgi_param           SCRIPT_FILENAME  /path.to.app/$fastcgi_script_name;
          include                 fastcgi_params;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
include /usr/local/nginx/sites-enabled/*;
    }
How can i make it work?