Laravel与Elasticbeanstalk:除'/'路由外,所有路由均返回404

时间:2020-05-11 11:16:09

标签: laravel amazon-elastic-beanstalk

我需要将非常简单的laravel 7应用程序部署到Elasticbeanstalk,我做了一切docs 一切正常,直到我单击除/路由以外的任何其他路由。

just like this tutorial(正在工作)

http://laravelbooksystem-env.eba-vmyh6fvn.us-east-2.elasticbeanstalk.com/(不起作用)

web.php

Route::get('/', function () {
    return view('welcome');
});


Route::get('/experts', 'ExpertsController@index');

Route::get('/experts/{id}/show', 'ExpertsController@show');

Route::get('/experts/{id}/book', 'AppointmentsController@display');


Route::post('/appointment/{id}', 'AppointmentsController@store');

.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

.ebextensions

container_commands:
    01_clear_config:
        command: "php artisan config:clear"
    02_clear_cache:
        command: "php artisan cache:clear"    
    03_build_db:
        command: "php artisan migrate --force"
    04_seed:
        command: "php artisan db:seed --force"    

有关如何解决此问题的任何线索?

1 个答案:

答案 0 :(得分:1)

我遇到了这个问题,并按照niallD在此处发布的说明修复了该问题: Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1