Chuyển hướng Redirect 301 trong Laravel

0
0
(0)

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

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave A Reply

Your email address will not be published.