社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

Nginx上的Laravel API route get 404

m6devin • 4 年前 • 600 次点击  

我有一个大型项目。它可以在带有nginx的Mac操作系统上工作。 我最近安装了一个CentOs 8。我在上面安装了Nginx并添加了如下配置:


server {
    listen 8001;
    server_name _;
    root /usr/share/nginx/html/reservation_laravel/public;

    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;

    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; }

    error_page 404 /index.php;

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

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


web.php中的所有路由都工作正常,但API路由不工作! 在Ubuntu服务器上也有同样的配置!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/51716
 
600 次点击  
文章 [ 2 ]  |  最新文章 4 年前
A. Bechir
Reply   •   1 楼
A. Bechir    4 年前

我不确定你是否有重写的问题。请看一下Laravel的安装文档。有一个关于重写配置的部分可能会让您有所了解:

https://laravel.com/docs/6.x/installation#pretty-urls

albus_severus
Reply   •   2 楼
albus_severus    4 年前

在api.php上编写时,在url上添加如下api

'/get-list'

那你就叫它

 /api/get-list