NginX:别名和位置

Hello StackOverflowers,

I'm struggling for more than a day on this problem. I have 2 sites, one is the application and one is the front wordpress.

The files are as follow :

  • Application : C:/Users/NICOLAS/Documents/www/index.php
  • Wordpress : C:/Users/NICOLAS/Documents/www/wordpress/index.php

The problem is that I'm moving from apache to nginx and I can't change the URLs. The mapping must be like that :

I failed to configure NginX to do that. I dont know why, this configuration makes me headash ! I still don't get the logic of NginX. Here is the important part of my conf :

root C:\Users\NICOLAS\Documents\www;
location ~ ^/v1/(.+\.php.*)$ {
    alias "C:/Users/NICOLAS/Documents/www/$1";
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
        include        fastcgi_params;
    }
}

location ~ / {
    alias C:/Users/NICOLAS/Documents/www/wordpress/;
    location ~ \.php$ {fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Can you point me out where is my mistake ?

Thank you !

I think the follow will works:

location /v1 {
  alias "C:/Users/NICOLAS/Documents/www/";
  location ~ \.php$ {
    # php-specific part
  }

location / {
  alias C:/Users/NICOLAS/Documents/www/wordpress/;
  location ~ \.php$ {
    # php-specific part
  }
}

Your first location doesn't work because alias wants a directory.

And maybe you would check nginx's logfiles.