Rewrite a url on Nginx

Posted by Ido B on Server Fault See other posts from Server Fault or by Ido B
Published on 2012-12-10T10:59:13Z Indexed on 2012/12/10 11:09 UTC
Read the original article Hit count: 234

Filed under:

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?

© Server Fault or respective owner

Related posts about nginx