0

希望让我的链接从example.com/page.phpexample.com/page

我在静态网站上使用 Valet for Windows,但似乎无法弄清楚如何配置我的 site.conf 文件,如下所示:

server {
    listen 80;
    server_name sp.test www.sp.test *.sp.test;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name sp.test www.sp.test *.sp.test;
    root /;
    charset utf-8;
    client_max_body_size 128M;

    location ~* /41c270e4-5535-4daa-b23e-c269744c2f45/([A-Z]+:)(.*) {
        internal;
        alias $1;
        try_files $2 $2/;
    }

    ssl_certificate "C:/Users/AJ/.config/valet/Certificates/sp.test.crt";
    ssl_certificate_key "C:/Users/AJ/.config/valet/Certificates/sp.test.key";

    location / {
        rewrite ^ "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php" last;
    }

    access_log off;
    error_log "C:/Users/AJ/.config/valet/Log/nginx-error.log";

    error_page 404 "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9001;
        fastcgi_index "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";
        fastcgi_param HOME 'C:/Users/AJ';
    }

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

server {
    listen 60;
    server_name sp.test www.sp.test *.sp.test;
    root /;
    charset utf-8;
    client_max_body_size 128M;

    location ~* /41c270e4-5535-4daa-b23e-c269744c2f45/([A-Z]+:)(.*) {
        internal;
        alias $1;
        try_files $2 $2/;
    }

    location / {
        rewrite ^ "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php" last;
    }

    access_log off;
    error_log "C:/Users/AJ/.config/valet/Log/nginx-error.log";

    error_page 404 "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9001;
        fastcgi_index "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "C:/Users/AJ/AppData/Roaming/Composer/vendor/cretueusebiu/valet-windows/server.php";
        fastcgi_param HOME 'C:/Users/AJ';
    }

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

基于SO的其他一些答案,我尝试了以下方法无济于事:

location / {
    try_files $uri $uri.html $uri/ @extensionless-php;
    index index.html index.htm index.php;
}

location ~ \.php$ {
    try_files $uri =404;
}

location @extensionless-php {
    rewrite ^(.*)$ $1.php last;
}

我通常使用 apache / .htaccess,所以编辑 conf 文件对我来说有点陌生,有什么想法吗?

4

0 回答 0