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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:03:56+00:00 2026-05-20T04:03:56+00:00

I am trying to figure out how to make it so that if a

  • 0

I am trying to figure out how to make it so that if a user types in a url and gets a 404 error message, they get routed to wordpress to see if it can figure out the url.

Currently I have a site
xyz.com where it is a wordpress site. I am designing a replacement where xyz.com will be a codeigniter site. I will keep the wordpress part xyz.com/blog will be wordpress.

I would like the old urls that are on search engines to be able to redirect to the blog that still has the same data as before, but is now under /blog.

What would be the best way to accomplish this.

Thanks

  • 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-20T04:03:56+00:00Added an answer on May 20, 2026 at 4:03 am

    This would send any 404s to a custom “/error” controller, along with the original requested uri string:

    class MY_Exceptions extends CI_Exceptions{
    
        function __constructor(){
            parent::CI_Exceptions();
        }
    
        function show_404($page=''){
            header('Location: /error'.$_SERVER['REQUEST_URI']);
            exit;
        }
    }
    

    the controller could then get the URI string, add “/blog/” in front of it, and check if the file exists. If it does, redirect… if not, go to another error page. So in the controller “error”:

    function index()
    {
        $this->load->helper('url');
        // remove "/error" from the uri
        $uri = substr($this->uri->uri_string(),0,6);
        $newuri = base_url() . "blog" . $uri;
        if(file_exists($newuri)):
            redirect($newuri,'location',301);
        else:
            redirect("/anotherErrorPage");
        endif;
    }
    

    I hope that helps!

    update: originally thought to use htaccess, but since everything in CI goes through, index.php…. that really isn’t needed.

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

Sidebar

Related Questions

I'm trying to figure out how to make it so that when I'm moving
I am trying to figure out how to make my layout have the following
I'm trying to figure out how to make jQuery slide #content2 down and replace
I'm trying to figure out a way to make demos for a program I've
I've been trying to figure out how I can make a query with MySQL
I'm trying to figure out how if there's a way to make a hostname
I'm trying to figure out how my iOS app should work after Facebook make
I'm trying to make getJSON to use JSONP object, but I can't figure out
I'm trying to figure out how to make the VS2010 style for AvalonDock to
I read some suggestions but couldn't figure out how to make the query that

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.