Laravel 路由在虚拟主机中不起作用

Laravel routes not working in web host

我已经将 laravel 项目上传到共享主机,主页工作正常 这个:

Route::get('/','PageController@index'); 

有效,但是:

 Route::get('/stories', 'PageController@getStories'); 

不起作用。404 未找到错误

一般来说,除此

外,所有其他路线都不起作用
 Route::get('/','PageController@index'); 

无法通过 ssh 访问 web hosting.Can 谁能帮帮我 有什么问题?

您的虚拟主机必须启用 mod_rewrite。

您必须删除故事前的 /。 尝试写

Route::get('stories', 'PageController@getStories'); 

如果您使用 http://domain/stories to access route '/stories', try to see if http://domain/index.php/stories 适合您。如果是,则说明您的 htaccess 无法正常工作。通常,共享主机没有为 apache 启用重写引擎。

我的问题是我使用的是共享主机提供的临时域,在域名传播后(如共享主机所说)所有路由都有效。感谢回答

尝试:

http://yourdomain.com/index.php/stories

请检查您的主机是否启用了 htaccess。