dongyinzhi4689 2015-07-23 23:40
浏览 79

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 !

  • 写回答

1条回答 默认 最新

  • dongyi9082 2015-07-24 11:35
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题