• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Site Migrate

#1
[eluser]alainm[/eluser]
Ok, i have looked at the documentation, and i'm a little confused.

I have an existing site that is built in php.

I want to move this site to code igniter, but i would like to migrate it slowly, so that i co-exists nicely with my other code igniter application.

So, i'm attempting to follow the instructions: http://codeigniter.com/wiki/site_migrate/

i created the directory system/application/views/site_migrate

Now i'm to the point where the index.php page pulls up, but it can't located the css files also the image files.

do i need to modify the site to have specific path?

also from my menu, how to i refer to the pages? example about.php this file used to be in the docroot. now if i click on the menu item, it's still thinks its located in the docroot. do i need to make a change there also?

thanks for you help.

cheers,
Alain

#2
[eluser]bretticus[/eluser]
Use absolute paths for your images and css files, etc.

If your website URL is http://yoursite.tld/index.php/controller/method and you have an img tag using a relative path:

Code:
<img src="images/blinking.gif">

Than your browser will try to find it under http://yoursite.tld/index.php/controller/images and that is just not right. Smile

Just put a beginning slash before your images folder to designate the website root path. ie:

Code:
<img src="/images/blinking.gif">

Probably as simple as that.

#3
[eluser]n0xie[/eluser]
You might want to take a look at the method we use at Isset for migrating websites to CodeIgniter.

#4
[eluser]alainm[/eluser]
n0xie: do you have a sample of the My_Router that you built?

#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();
                
    }
}

#6
[eluser]alainm[/eluser]
I'm having some issues with this..

would you be able to share what the index.php looks like?

#7
[eluser]alainm[/eluser]
i have found my issue. thanks so much for all your help.

#8
[eluser]n0xie[/eluser]
No problem. Hope it was useful.

#9
[eluser]sophistry[/eluser]
hi,

for future reference here is the link to the site_migrate wiki forum thread:
http://ellislab.com/forums/viewthread/91182/

the wiki articles all have forum threads. i just stumbled on this by accident... glad you worked it out!

cheers.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.