Chuyển hướng Redirect 301 trong Laravel 0 (0)

Chuyển hướng Redirect 301 trong Laravel 0 (0)

Learn more »

Trong Laravel mặc định Class Redirect không chỉ định mã status chuyển hướng redirect.

Trong file route.php chúng ta có đoạn code sau:

  1. Route::get(‘foo’, function(){
  2. return Redirect::to(‘https://vinasupport.com’);
  3. });

Để chuyển hướng chỉ định mã code chúng ta thêm mã chuyển hướng vào đối số thứ 2 khi gọi class Redirect.

Redirect::to(<URI>, <status_code>);

Với <status_code> là mã HTTP Status. Các bạn tham khảo danh sách mã HTTP Status ở đây.

VD: Chuyển hướng Redirect 301 tới trang vinasupport.com

  1. Route::get(‘foo’, function(){
  2. return Redirect::to(‘https://vinasupport.com’, 301);
  3. });

Nguồn: vinasupport.com


All the options and events can be found in official documentation

Please reload the page to view the responsive functionalities