2014-07-14 35 views
0

我正在將我的個人網站轉換爲Laravel。我把舊的網站到public文件夾,並且具有以下包羅萬象的路線,回到屬於舊網站(放置在結束我的路線文件):Laravel爲什麼給我一個無限的重定向?

Route::any('{all}', array('use' => Redirect::to('{all}'))); 

我已經轉換了一次一頁,到目前爲止一切都進展順利。然而,將一個頁面,humor後,火狐給了我這個錯誤:

The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

我檢查了Apache日誌,並注意到它交替下面之間幾次:

"GET /humor HTTP/1.1"
"GET /humor/ HTTP/1.1"

相關路線:

Route::resource('humor', 'HumorController'); 

控制器的方法是:

public function index() { 
    return View::make("humor.index"); 
} 

的觀點是:

@extends('master') 

@section('title') 
    Humor 
@stop 

@section('content') 
    [snip] 
    <p><a href="/humor/jokes.php">Jokes</a></p> 
    <p><a href="/humor/jokes_new.php">Jokes (Testing)</a></p> 
    <p><a href="/humor/xkcd.php">xkcd</a></p> 
@stop 

這些鏈接是目前對舊網站的頁面。

回答

0

我終於明白,如​​果我試圖以/some/folder的形式訪問我的舊網站上的文件夾,它會自動重定向到/some/folder/並顯示內容。由於humor文件夾仍然存在於我的舊網站(public文件夾中)中,Apache試圖添加尾隨/並顯示內容。然而,我的.htaccess文件爲Laravel設置爲刪除尾隨/,因此他們相互爭鬥,造成無限循環。

我通過將humor目錄重命名爲publichumor_old並更新相關鏈接來解決此問題。

我在這裏回答了我自己的問題,因爲當我搜索Laravel和Firefox錯誤時,我想出了4個結果,這些結果都與我的問題不同。

相關問題