How do I migrate my existing \'normal\' PHP site to CodeIgniter?

Answer

Put the whole site in a subfolder of your root web folder, and use .htaccess to rewrite all requests to the subfolder (we named it ‘oldsite’ but any name will do). Be wary of absolute file paths (do a find on the entire codebase to look for any file that uses the filesystem). Make sure everything works before you continue any further.

Now setup your CI site in the root of the webfolder. Make sure the .htaccess still routes all traffic to the old site.

Now overwrite the Router class with a MY_Router. Let CI check if there is a controller present which matches against the url (the way it normally does). If not, redirect to the oldsite folder. Remove the .htaccess rule that redirects all traffic to the old site.

Now every request will go through the CI index.php. The Router Class will test if a controller exists for the requested url. (just like it would normally so you can user your routes in your config folder). If it won’ t find one, normally CI would return a 404. Instead it now redirects the request to the old site.

Now you can slowly migrate parts of the website. Since the CI controllers take precedent over the old website, you can slowly replace parts of the old websites, and add new features as you would a normal CI site.

One word of caution. This will seriously impact any pagerank google has given to your website, since google doesn’t like redirects. To counter this you can use your .htaccess to rewrite old urls to the ‘oldsite’ subfolder, although the list could become quite large.

All CODEIGNITER Questions

Ask your interview questions on codeigniter

Write Your comment or Questions if you want the answers on codeigniter from codeigniter Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---