【问题标题】:Nginx - Php subdirectory files keep redirecting to homepageNginx - Php 子目录文件不断重定向到主页
【发布时间】:2016-01-21 16:27:40
【问题描述】:

我似乎无法在任何地方找到适合我在线情况的解决方案。我的 nginx 配置为默认使用 bigbluebutton,所以我设置了 mysql 和 php 以使用蓝色大按钮位置。我已经成功地将 php 信息文件显示在文件的根目录中,但是如果我将文件放在子目录中,我会被重定向到根目录。子目录中的 html 文件不会发生这种情况,只有 .php 文件。最初我会在子目录中的 php 文件上得到 404,但现在我打开了短标签(即使没有使用,它也会将我重定向到大蓝的根目录。对不起,我很菜鸟,任何帮助都是真的很感激。

server {
 listen   80;
 server_name  **.**.***.**;

 access_log  /var/log/nginx/bigbluebutton.access.log;

 # Handle RTMPT (RTMP Tunneling).  Forwards requests
 # to Red5 on port 5080
  location ~ (/open/|/close/|/idle/|/send/|/fcs/) {
      proxy_pass         http://127.0.0.1:5080;
      proxy_redirect     off;
      proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;

      client_max_body_size       10m;
      client_body_buffer_size    128k;

      proxy_connect_timeout      90;
      proxy_send_timeout         90;
      proxy_read_timeout         90;

      proxy_buffering            off;
      keepalive_requests         1000000000;
  }

 # Handle desktop sharing tunneling.  Forwards
 # requests to Red5 on port 5080.
   location /deskshare {
       proxy_pass         http://127.0.0.1:5080;
       proxy_redirect     default;
       proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
       client_max_body_size       10m;
       client_body_buffer_size    128k;
       proxy_connect_timeout      90;
       proxy_send_timeout         90;
       proxy_read_timeout         90;
       proxy_buffer_size          4k;
       proxy_buffers              4 32k;
       proxy_busy_buffers_size    64k;
       proxy_temp_file_write_size 64k;
       include    fastcgi_params;
   }

# BigBlueButton landing page.
    location / {
      try_files $uri $uri/ /index.html;        
      root   /var/www/bigbluebutton-default;
      index index.php index.html index.htm;
  expires 1m;
    }

# Include specific rules for record and playback
    include /etc/bigbluebutton/nginx/*.nginx;

    error_page  404  /404.html;

    # Redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
            root   /var/www/nginx-default;
    }

location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME     
            $document_root$fastcgi_script_name;
            include fastcgi_params;

    }
}

【问题讨论】:

  • 请帮助...使用别名或根目录添加服务器位置块,并且各种配置不起作用...我只是不断被重定向,一定是我缺少一些东西...
  • 子目录的名称是什么?该子目录的路径是什么?
  • /kemsley 它位于 /var/www/bigbluebutton-default/kemsley 位置

标签: php redirect nginx


【解决方案1】:

您的location ~ \.php$ 块似乎没有设置root。如果您有多个location 块的共同根,您可能应该将root 指令向上移动到周围的server 块。像这个sn-p:

root /var/www/bigbluebutton-default;

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.html;        
    expires 1m;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    ...
}

【讨论】:

  • 是的!神奇!!!!!哦,我的天哪!!!!!!!!!!谢谢谢谢谢谢谢谢!!!!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-09
  • 2020-05-20
  • 1970-01-01
  • 2017-02-06
相关资源
最近更新 更多