Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:36:24+00:00 2026-06-11T11:36:24+00:00

Both are working, but I am asking if there is any difference or can

  • 0

Both are working, but I am asking if there is any difference or can I just use redirect(); ?

So from these 3 variants, which one is the one that I should stick to?

redirect('/');

or

redirect('');

or

redirect();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:36:26+00:00Added an answer on June 11, 2026 at 11:36 am

    If you look at the source you can see that it appends the given URL to the site_url.

    function redirect($uri = '', $method = 'location', $http_response_code = 302)
    {
        if ( ! preg_match('#^https?://#i', $uri))
        {
            $uri = site_url($uri);
        }
    
        switch($method)
        {
            case 'refresh'  : header("Refresh:0;url=".$uri);
                break;
            default         : header("Location: ".$uri, TRUE, $http_response_code);
                break;
        }
        exit;
    }
    

    So like you said, all those options work.
    But I would personally recommend to use:

    redirect('/');
    

    If you work with multiple developers this is easier to understand for those who are not familiar with CodeIgniter, since most developer know that “/” refers to the “root directory”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These 2 ways of working both work, but I'm wondering if there's a difference
I'm working with strings that contain both digits and alphanumerics, or just digits, but
Both methods MyBehavior::CreateSerializer() are not called of some reason, but ReplaceBehavior() method is working.
The following JQuery function is not working entirely. IE 7 processes both alerts, but
I'm working on an ASP.NET web application. There's a bill page which has two
There are two places where I have observed this. Both are AJAX calls which
A co-worker and I are both working on the master branch at the moment.
Could someone tell if it's possible to get an OpenCL code working with both
I'm working with backbone and lazy-loading both templates and data for one of my
I am working with NSScanner to parse data that is both comma and line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.