[英]NginX : alias and location
Hello StackOverflowers, 您好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. 我有2个站点,一个是应用程序,一个是前台wordpress。
The files are as follow : 文件如下:
- Application : C:/Users/NICOLAS/Documents/www/index.php 应用程序:C:/Users/NICOLAS/Documents/www/index.php
- Wordpress : C:/Users/NICOLAS/Documents/www/wordpress/index.php WordPress:C:/用户/NICOLAS/Documents/www/wordpress/index.php
The problem is that I'm moving from apache to nginx and I can't change the URLs. 问题是我正在从apache迁移到nginx,并且无法更改URL。 The mapping must be like that : 映射必须是这样的:
- Application : http://test.site/v1/index.php/products/view/shoes must get 应用程序:必须获得http://test.site/v1/index.php/products/view/shoes
- www/index.php/products/view/shoes WWW / index.php文件/产品/视图/鞋
- Wordpress : http://test.site/index.php must get WordPress: http : //test.site/index.php必须获得
- www/wordpress/index.php WWW / WordPress的/ index.php的
I failed to configure NginX to do that. 我无法配置NginX来做到这一点。 I dont know why, this configuration makes me headash ! 我不知道为什么,这种配置让我头晕! I still don't get the logic of NginX. 我仍然不了解NginX的逻辑。 Here is the important part of my conf : 这是我的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. 您的第一个位置不起作用,因为alias
一个目录。
And maybe you would check nginx
's logfiles. 也许您会检查nginx
的日志文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.