Welcome Guest, Not a member yet? Register   Sign In
Site Migrate
#5

[eluser]n0xie[/eluser]
Code:
class MY_Router extends CI_Router {

  function MY_Router()
  {
    parent::CI_Router();
  }

  // copy pasted from original Router.php

      function _validate_request($segments)
    {
        // Does the requested controller exist in the root folder?
        if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
        {
            return $segments;
        }

        // Is the controller in a sub-folder?
        if (is_dir(APPPATH.'controllers/'.$segments[0]))
        {        
            // Set the directory and remove it from the segment array
            $this->set_directory($segments[0]);
            $segments = array_slice($segments, 1);
            
            if (count($segments) > 0)
            {
                // Does the requested controller exist in the sub-folder?
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
                {
                    show_404($this->fetch_directory().$segments[0]);
                }
            }
            else
            {
                $this->set_class($this->default_controller);
                $this->set_method('index');
            
                // Does the default controller exist in the sub-folder?
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
                {
                    $this->directory = '';
                    return array();
                }
            
            }

            return $segments;
        }

    /* this is the only bit you want to change.
     * normally CI will send a 404 when no controller is found
     * instead we are going to redirect to the oldsite
     */

        // Can't find the requested controller...
        //show_404($segments[0]);
      
                // this depends on how you setup your oldsite:
                $ext_url = 'http://'. $_SERVER['SERVER_NAME'] . '/oldsite' . $_SERVER["REQUEST_URI"];
              header ('HTTP/1.1 301 Moved Permanently');
              header ('Location: '.$ext_url);
              exit();
                
    }
}


Messages In This Thread
Site Migrate - by El Forum - 01-21-2010, 10:47 PM
Site Migrate - by El Forum - 01-21-2010, 10:54 PM
Site Migrate - by El Forum - 01-22-2010, 03:58 AM
Site Migrate - by El Forum - 01-22-2010, 09:08 AM
Site Migrate - by El Forum - 01-22-2010, 09:35 AM
Site Migrate - by El Forum - 01-24-2010, 09:01 AM
Site Migrate - by El Forum - 01-24-2010, 10:33 AM
Site Migrate - by El Forum - 01-24-2010, 04:38 PM
Site Migrate - by El Forum - 01-25-2010, 08:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB