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 7048389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:53:10+00:00 2026-05-28T02:53:10+00:00

Iam developing a site in codeigniter.This is my url http://myserver.net/visio/UBwXo . Here h ttp://myserver.net/visio/

  • 0

Iam developing a site in codeigniter.This is my url http://myserver.net/visio/UBwXo.
Here http://myserver.net/visio/ is my base_url.

After /visio/ here have a variable.When there have any value after /visio/ then i wantto take the corresponding url from database to this value.

That means in my database,

UBwXo => “*any url***“

jshom => “*any url***“

So when getting value after /visio/ i want to take the corresponding url from databse and redirect it in to that url without using htaccess.

I want to done this redirection process in index.php page of root folder.

Is this possible?

The orginal url for http://myserver.net/visio/UBwXo like myserver.net/visio/index.php/admin/index/UBwXo

the default controller is admin

  • 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-05-28T02:53:10+00:00Added an answer on May 28, 2026 at 2:53 am

    First, create redirect.php file in the controllers folder (application/controllers) and add this code to this file:

    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
    
    class Redirect extends CI_Controller
    {
    
        /**
         * Method to redirect from an alias to a full URL
         */
        public function index()
        {
    
        $alias = $this->uri->segment(1);
    
        $this->db->select('url');
    
        $query = $this->db->get_where('links', array('alias' => $alias), 1, 0);
    
        if ($query->num_rows() > 0)
        {
            foreach ($query->result() as $row)
            {
            $this->load->helper('url');
    
            redirect($row->url, 'refresh', 301);
            }
        }
        else
        {
            echo "Sorry, alias '$alias' not found";
        }
        }
    
    }
    

    Then create table in your database. Your table must be like this:

    CREATE TABLE IF NOT EXISTS `links` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `alias` varchar(6) CHARACTER SET utf8 DEFAULT NULL,
      `url` text CHARACTER SET utf8,
      PRIMARY KEY (`id`),
      UNIQUE KEY `alias` (`alias`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
    

    After that, set default controller value to the redirect class.
    Open application/config/routes.php. Find $route['default_controller'] , then set redirect as a value to this variable, like this:

    $route['default_controller'] = "redirect";
    

    Then enjoy life 😉

    EDIT:

    I had forgotten to mention URI routing in config/routes.php for redirecting:

    $route[':any'] = "redirect/index/$1";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing a site which demo URL is http://www.abc.com now my client wants
I am developing a site in asp.net mvc 2.0 .Here i want to send
I am developing a site using asp.net and C# ( framework 1.1 ). Theres
I am developing a site (ASP.Net based) that, besides other features enables the users
I am developing a site using ASP.NET 2.0. AjaxToolKit's ModalPopupExtender is being used to
I am developing a site using ASP.NET, SQL 2008 and LINQ. I want to
I am developing site using codeigniter.I have a form which contains add button and
I am developing a site using Asp.net MVC 3 with Razor. In the _Layout.cshtml
I am developing a site, you can see the code in this link. I
I am developing this site, it got my CSS file, and also have references

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.