簡體   English   中英

Laravel:routes.php中的Redirect :: to()無法正常工作

[英]Laravel: Redirect::to() in routes.php not working

在routes.php中,我在所有路由上方都具有以下代碼:

# Lang::get('routes.page') = 'page';
if (preg_match('/\\/'.Lang::get('routes.page').'-[0-9]+/i',
    $_SERVER['REQUEST_URI'], $matches)) {
    if (isset($matches[0]) and strtolower($matches[0]) !== $matches[0]) {
        $url = str_ireplace(
            '/'.Lang::get('routes.page').'-', 
            '/'.Lang::get('routes.page').'-',
            $_SERVER['REQUEST_URI']
        );
        return Redirect::to($url, 301);
    }
}

這給了我錯誤:

異常處理程序中的錯誤:路由[content]未定義。 (檢視:/path/to/app/views/view.blade.php)(檢視:/path/to/app/views/view.blade.php)在/ path / to / vendor / laravel / framework / src / Illuminate / Routing / UrlGenerator.php:231

這是Laravel 4.2。 為什么會出現此錯誤?

您的路線中沒有“ views / view.blade.php”中的錯誤。 可能是這樣

// ....
//
{{route('content')}}
// [or]
{{URL::route('content')}}
// ....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM