NGINX的配置只能获取根目录,否则将发送到没有别名的错误屏幕

时间:2019-01-03 19:51:15

标签: wordpress laravel nginx laravel-forge

我正在尝试将现有laravel网站的特定子目录链接到wordpress安装。由于某些原因,根可以工作,但是wordpress根的所有子目录都没有指向该文件夹。

我试图将通配符添加到指向的位置,但似乎并不想将其提取。

    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name .swyftfilings.us;
        root /home/forge/swyftfilings.us/public;

        # FORGE SSL (DO NOT REMOVE!)
        ssl_certificate /etc/nginx/ssl/swyftfilings.us/457933/server.crt;
        ssl_certificate_key /etc/nginx/ssl/swyftfilings.us/457933/server.key;

        ssl_protocols TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
        ssl_prefer_server_ciphers on;
        ssl_dhparam /etc/nginx/dhparams.pem;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

        index index.html index.htm index.php;

        charset utf-8;

        # FORGE CONFIG (DO NOT REMOVE!)
        include forge-conf/swyftfilings.us/server/*;

        location /learning-center {

            alias /home/forge/learning-center/public;

            try_files $uri $uri/ /index.php?$query_string;


            location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
            }

        }

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        access_log off;
        error_log  /var/log/nginx/swyftfilings.us-error.log error;

        error_page 404 /index.php;

        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }

        location ~ /\.(?!well-known).* {
            deny all;
        }
    }

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/swyftfilings.us/after/*;

期望url子目录/ learning-center / {anything here}在“ learning-center / public”目录中进行搜索,但是只有/ learning-center可以。

编辑:看来它将起作用,但仅适用于以.php结尾的文件

0 个答案:

没有答案
相关问题