这是我正在处理的遗留代码,我不能改变它发布到哪里,所以我只需要找出一个方法。
一点的Javascript做一个职位如下 –
POST /authentication/login/
这是非常奇怪的,因为它张贴到一个目录,但无论如何,我想configurationNginx接受到这个位置的post,然后将它们传递给我的Nginxconfiguration中的一点PHP我有以下内部一个http块
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /authentication/login/ { index hello.php; #root html; #index /usr/local/nginx/html/hello.php; } location ~.php$ { include /usr/local/nginx/conf/fastcgi_params; fastcgi_pass 127.0.0.1:9000; } }
PHP的东西的作品,我可以直接进入hello.php和那个作品。
我的错误日志/访问日志并不真的给我很多。 我在hello.php上得到了一个404,但是通过放入“index”来解决这个问题。但是,这永远不会导致PHP的调用。 我也尝试把fastcgi的东西放入nginx.conf中的/ authenticate / login / location。
关键在于,如果我发布一些/ authenticate /login我想调用一块PHP返回所需的值。
什么是写这个位置块的正确方法? 有任何想法吗?
你需要指定确切的位置才能让nginx在〜.php {}块中处理它,复制fastcgi参数,这样url就会被传递给php,并且用重写规则改变uri。 configuration块与login位置应该是这样的:
location = /authentication/login/ { rewrite ^(.*) /hello.php last; include /usr/local/nginx/conf/fastcgi_params; fastcgi_pass 127.0.0.1:9000; }