Laravel配置路由

2021-06-22 21:35:07 字數 1060 閱讀 8810

route::get('/', function()

);route::get('test', function());

在瀏覽器中輸入192.168.xx.xx, 可以看到網頁返回了get/ hello world,如果沒有返回,

重啟以下httpd,apatch伺服器:

在瀏覽器中輸入192.168.xx.xx/test,如果返回失敗,則試一下192.168.xx.xx/index.php/test,如果返回成功,說明沒有隱藏index.php.

在public檔案加下新增檔案:

vi .htaccess

內容為: #

options +followsymlinks

rewriteengine on

rewritecond % !-d

rewritecond % !-f

rewriterule ^ index.php [l]

#ewrite是apache環境的乙個偽靜態功能了,如果我們沒有沒讓apache開啟rewrite功能,**上所有的rewrite規則都不可使用

centos的配置檔案放在: /etc/httpd/conf/httpd.conf

開啟檔案找到:

**如下

複製**

loadmodule rewrite_module modules/mod_rewrite.so

將前面"#"去掉,如果不存在則新增上句。

如果你的**是根目錄的話:找到

**如下

複製**

options followsymlinks

allowoverride none  

將上面的none改為all

如果你的站點不在根目錄,設定如下:

**如下

複製**

order allow,deny

allow from all

allowoverride all

ok,然後重啟伺服器,service httpd restart ,這樣.htaccess就可以使用了。

laravel學習筆記之路由

路由 寫在http下的routes.php中 基礎路由 route get basic1 function route post basic2 function 多請求路由 match 註冊乙個指定的多路由請求 route match get post multy1 function any 註冊乙...

laravel 訪問時自動生成路由規則

路由訪問時自動生成 路由訪問時自動生成 if php sapi name cli 定製路由規則,覆蓋上面規則 首頁 route group middleware checklogin function 建立路由規則 param string method 請求方法 param string path...

Laravel 伺服器配置 1

1 安裝ubuntu server 配置ip sudo nano etc network inte ce 更改sources.list檔案 deb utopic main restricted universe multiverse deb utopic security main restrict...