From 05f830c7105ef3cd4a8388bffe7cf73c35236105 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Sun, 27 Apr 2008 13:35:20 +0000 Subject: Added the ability to include an optional HTTP Response Code in the redirect() function of the URL Helper. --- user_guide/helpers/url_helper.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'user_guide/helpers') diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index 3efb7ed5f..7bda86da9 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -18,7 +18,6 @@ - @@ -231,16 +230,20 @@ $url = prep_url($url); to redirect to a local URL within your site. You will not specify the full site URL, but rather simply the URI segments to the controller you want to direct to. The function will build the URL based on your config file values.

-

The second parameter allows you to choose between the "location" -method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. Example:

+

The optional second parameter allows you to choose between the "location" +method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is only available with 'location' redirects, and not 'refresh'. Examples:

if ($logged_in == FALSE)
{
     redirect('/login/form/', 'refresh');
-}
+}
+
+// with 301 redirect
+redirect('/article/13', 'location', 301);

Note: In order for this function to work it must be used before anything is outputted -to the browser since it utilizes server headers.

+to the browser since it utilizes server headers.
+Note: For very fine grained control over headers, you should use the Output Library's set_header() function.

-- cgit v1.2.3-24-g4f1b