【问题标题】:routes redirect me to home page ( laravel )路线将我重定向到主页(laravel)
【发布时间】:2023-04-02 07:30:01
【问题描述】:

好的 现在我用 apache 和 nginx 代理在 ubuntu 14.4 上安装了 laravel 4.2。

当我创建像

这样的路线时
Route::get('/reg', function()
{
    return 'hii';
});

当我调用“localhost:8080/reg”时,apache 会查看“hii”

但是当我在浏览器中调用“localhost/reg”时,nginx 会查看主页

nginx 配置:

server {
        listen   80;

        root /var/www/laravel/public;
        index index.php index.html index.htm;

        server_name localhost;

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

    if (!-d $request_filename) {
        rewrite     ^/(.+)/$ /$1 permanent;
    }

        location ~ \.php$ {

        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;

         }

 # PHP FPM configuration.
    location ~* \.php$ {
            fastcgi_pass                    unix:/var/run/php5-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_split_path_info         ^(.+\.php)(.*)$;
            include                         /etc/nginx/fastcgi_params;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script$
    }

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

哪里错了?

【问题讨论】:

    标签: apache nginx laravel-4 ubuntu-14.04


    【解决方案1】:

    根据您的nginx.conf,它正在加载您的/var/www/laravel/public/index.php;。如果你不希望这种情况发生,

    • nginx.conf中的路径调整为你要load的文件,

    OR

    • 创建一个视图,然后将路径指向该视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 2023-01-27
      • 2016-07-12
      • 2015-09-20
      • 2018-12-08
      • 2022-01-22
      相关资源
      最近更新 更多