Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php nginx-友好的URL';它在目录中_Php_Linux_Nginx_Friendly Url - Fatal编程技术网

Php nginx-友好的URL';它在目录中

Php nginx-友好的URL';它在目录中,php,linux,nginx,friendly-url,Php,Linux,Nginx,Friendly Url,我将我的友好URL从Apache移动到nginx,我遇到了一个问题。我想知道友好URL只在子目录sgforum中起作用 在PHP中,我收到的地址是:127.0.0.1/sgforum/index,127.0.0.1/sgforum/member等 当我使用127.0.0.1/sgforum/-它工作时,但是当我给成员(127.0.0.1/sgforum/member)或索引时,它会将文件下载到我的计算机,而不是用php打开 这是我的/etc/nginx/sites available/defau

我将我的友好URL从Apache移动到nginx,我遇到了一个问题。我想知道友好URL只在子目录sgforum中起作用

在PHP中,我收到的地址是:127.0.0.1/sgforum/index127.0.0.1/sgforum/member

当我使用127.0.0.1/sgforum/-它工作时,但是当我给成员(127.0.0.1/sgforum/member)或索引时,它会将文件下载到我的计算机,而不是用php打开

这是我的/etc/nginx/sites available/default文件:

server {
    listen 80 default_server;
    #listen [::]:80 default_server;

    root /home/ariel/workspace;

    index index.php index.html;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # FRIENDLY URLS
    location /sgforum/ {
        if (!-e $request_filename){
            rewrite ^/sgforum/(.*)$ /sgforum/index.php break;
        }
    }

    location ~ /\.ht {
        deny all;
    }
}

您必须为成员文件夹设置位置

尝试更改

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

我改变了它,终于它应该工作了

# FRIENDLY URLS
location /sgforum/ {
    try_files $uri $uri/ /sgforum/index.php;
}

member-不是目录,它是一个参数,在PHP$\u服务器['REQUEST\u URI']中回答并选择特定操作。下载文件时,意味着您必须调整PHP fpmsettings@MeiramChuzhenbayev,你能把你的两个答案作为一个完整的答案贴出来吗?现在我有404作为输入的任何短语,但是仍然将正确的URL保存为sgforum/member-to-file-member。有一个类似的问题,这对我很有用。谢谢