laravel第一個路由程序失敗 Object not found! Error 404

注:本文全部圖片保存EverNote 印象筆記(www.yinxiang.com)當中, 若是有其賬號登陸後便可查看所有圖片。

 

接觸php兩個月了,開始學習laravel框架。看了則修網上講laravel4的幾個視頻和laravel文檔中的安裝、配置、路由、錯誤和日誌,在windows上搭建好相應環境(apache、php採用xampp),準備實踐。php


代碼

修改app-route.phplaravel

Route::get('/', function()
{
    return View::make('hello');
});

Route::get('about', function()
{
    return "hello world";
});

問題

結果在瀏覽器中訪問根目錄時能夠訪問頁面,而訪問about頁面則提示Object not found! Error 404
Alt textweb

Alt text

未能解決問題的方法

Route::get('/about' 多一個'/'就好了
—— 百度知道apache


在公司搭建的laravel 框架一切正常 代碼拷貝到另外一臺電腦以後 ROUTE的配置沒有生效
好比http://localhost/admin
這個連接是有route配置的 但是直接404報錯 而且不是指定的404頁面
是wamp的問題 仍是.htaccess的問題
求教windows

解決了 apache conf 配置中的AllowOverride 要改爲All
——開源中國社區瀏覽器

何嘗試的方法

Look into your /etc/httpd.conf file and see if you have Virtual hosts activated.app

enter code here框架

If so, check your etc/extra/httpd-vhosts.conf file. You might have set up a VirtualHost already.ide

EDIT: I have found that once you turn on Virtual Hosts, XAMPP needs a default VirtualHost for your basic htdocs files學習

Try adding a default VirtualHost (at the bottom of the file) like so:

<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"

<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
——stackoverflow

有效的方法

I don't know if you're running L4 or L3. However, launch CLI and

$ cd ./path/to/project

Then for L4:

$ php artisan serve
For L3:

$ php -S localhost:8000 -t public
Now you can go to localhost:8000 and see your application.
——stackoverflow

也就是不使用apache,使用laravel中的artisan來提供web服務
Alt text

總結

問題算是暫時解決了,用apache提供web服務的方法還得繼續研究。