簡體   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