laravel 路由在 ip 地址上不起作用

laravel routing not working on ip address

我在 vps 服务器上实施 laravel,只有一个 IP 地址,没有域。

它的工作并显示索引文件但路由不工作并显示 404 未找到页面。

这是我的 web.php 文件:

<?php


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

Route::get('/test' , function(){
    return 'this is test route';
});

并在 .env 文件中设置 ip:

APP_URL=http://178.63.245.92

这是我的 vps 的 IP 地址:http://178.63.245.92/

当我说:http://178.63.245.92/test 它说:

Not Found
The requested URL /test was not found on this server.

需要做什么。

谢谢。

您可以使用此命令将路由设置为所需的 IP 地址

php artisan serve --host 178.63.245.92 --port 80

@IlGala 感谢您指出 my mod_rewrite 模块,我的 mod_rewrite 模块已启用,但我在您启用 my mod_rewrite 后阅读 here 您必须允许 Apache读取位于 /var/www/html 目录下的 .htaccess 文件。 我授予访问权限,正如该页面上的结构所说,它已解决。

谢谢大家。