繁体   English   中英

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

[英]laravel routing not working on ip address

我在只有 ip 地址且没有域的 vps 服务器上实现 laravel。

它的工作并显示索引文件,但路由不起作用并显示 404 not found 页面。

这是我的 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.

必须做什么。

谢谢。

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

谢谢大家。

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

php artisan serve --host 178.63.245.92 --port 80

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM