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

Integrations
Users

Share Profile

Anyone at KeenThemes can view
Anyone with link can edit

Give Award

Anyone at KeenThemes can view
Anyone with link can edit

Report User

Let us know why you’re reporing this person
Don't worry, your report is completely anonymous; the person you're
reporting will not be informed that you've submitted it