Hello StackOverflowers,
这个问题我已经纠结了一天多了。我有两个站点,一个是应用程序,一个是前端wordpress。文件如下:
- 应用程序:C:/Users/NICOLAS/Documents/www/index.php
- Wordpress: C:/Users/NICOLAS/Documents/www/Wordpress/index.php
问题是,我从apache移动到nginx,我不能改变url。映射必须是这样的:
- 应用程序:http://test.site/v1/index.php/products/view/shoes必须得到
- www/index . php/产品/视图/鞋
- Wordpress: http://test.site/index.php必须得到
- www/wordpress/index . php
我没有把NginX配置成那样。我不知道为什么,这个配置让我头疼!我还是不明白NginX的逻辑。下面是我的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;
}
}
你能指出我错在哪里吗?
我认为下面的方法可以奏效:
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
}
}
你的第一个位置不工作,因为alias
需要一个目录。
也许你应该检查nginx
的日志文件。