How to do 301 redirects in CodeIgniter?

by kade.hermiston , in category: Technology , 3 years ago

How to do 301 redirects in CodeIgniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cristobal , 3 years ago

We can use redirect helper to do 301 redirects in Codeigniter.

Syntax :

1
 redirect($uri = '', $method = 'auto', $code = NULL)

Parameter:

1
2
3
    $uri (string)  URI string
    $method (string)  Redirect method (‘auto’, ‘location’ or ‘refresh’)
    $code (string)  HTTP Response code (usually 302 or 303)

Return type: void

Sample Usage:-

1
redirect('/posts/13', 'New location', 301);