Welcome Guest, Not a member yet? Register   Sign In
From Procedural to Object Oriented: CI Style
#1

[eluser]wolfman2000[/eluser]
As I mentioned in my introduction thread, I wish to use CodeIgnitor for my website from here on out. The problem is that it is currently in a procedural format, and I can't easily change everything overnight without disrupting normal viewing. If it helps, with the exception of some particular image files, every relevant page is inside the www folder.

Would a good plan be as follows?

1) Make a new folder in www for CodeIgnitor. Say this folder is called "ci" for now.
2) Move www/ci/system/application to www/ci/system.
3) Clone the database data into another database for private testing (I have that functionality).
4) Build everything a bit at a time until it's complete and properly tested.
5) Move the contents of www/ci into www/.
6) ???
7) PROFIT!


I can offer limited peaks at my PHP code upon request.
#2

[eluser]wiredesignz[/eluser]
Sounds like a plan to me, Welcome to CI forums.
#3

[eluser]wolfman2000[/eluser]
It's times like this I'm glad to see a "#### characters remaining" counter...wait, better get to work! :-)

I have a basic CI setup on my page at the moment: http://www.pumpproedits.com/CodeIgniter_...hp/welcome However, I cannot type in http://www.pumpproedits.com/CodeIgniter and get the page I am after: I get 404'd. I want that index.php requirement to be gone. I was prompted by sikkle on the IRC room to study the Mod Rewrite Wiki. I have most of the steps completed without the main website interfering. However, it is Steps 3 & 4 that are causing problems.

I will go over all of the steps anyway as a sort of sanity check.

Step 1) Modify .htaccess

I can modify my .htaccess via online editor, so I do that. Here is what I have.
Code:
RewriteEngine on

Options All -Indexes

AddHandler application/x-httpd-php5 .php

SetEnvIfNoCase User-Agent "^netcraft" bad_bot

<Limit GET POST HEAD>
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</Limit>

RewriteCond %{HTTP_REFERER} !^http://pumpproedits.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://pumpproedits.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pumpproedits.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pumpproedits.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CodeIgniter_1.6.1/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Step 2) Modify application/config/config.php so that $config['index_page'] = "";

That was easily done. While I was at it, I changed $config['base_url'] = "http://{$_SERVER['SERVER_NAME']}/CodeIgniter_1.6.1/"; No other options were changed.

Step 3) Ensure mod_rewrite is activated.

I already had RewriteEngine On as the first line of my .htaccess file. I assumed that was enough.

Step 4) Make sure apache accepts needed .htaccess directives.

I had trouble figuring out what directory goes in <Directory>. My following attempts ended up in failure.
Code:
#<Directory "/CodeIgniter_1.6.1/">
#Options Indexes Includes FollowSymLinks MultiViews
#AllowOverride AuthConfig FileInfo
#Order allow,deny
#Allow from all
#</Directory>

#<Directory "/CodeIgniter_1.6.1">
#Options FollowSymLinks
#AllowOverride FileInfo
#</Directory>

Any time I tried uncommenting a whole block, the entire website went down. Needless to say, I'm doing something wrong, but I am unsure what.

Step 5) Restart apache.

There is probably a way for me to do this, even with the command line. However, I am unsure of how yet.

If it matters, my server is using Apache 1.3.37 on Unix (insert geek joke here). Step 3 involved some commands using apache2, but I do not have that.

If I'm lucky, this is just a simple thing that can be fixed...without taking down the entire website again.
#4

[eluser]bradym[/eluser]
[quote author="wolfman2000" date="1207432993"]It's times like this I'm glad to see a
Step 3) Ensure mod_rewrite is activated.

I already had RewriteEngine On as the first line of my .htaccess file. I assumed that was enough.
[/quote]

Not quite. You need to make sure mod_rewrite is enabled in your httpd.conf or the RewriteEngine On line will cause a 500 error.

Open your httpd.conf and look for the line that says "LoadModule rewrite_module modules/mod_rewrite.so" and make sure it is not commented out.

Quote:Step 4) Make sure apache accepts needed .htaccess directives.

I had trouble figuring out what directory goes in <Directory>. My following attempts ended up in failure.
Code:
#<Directory "/CodeIgniter_1.6.1/">
#Options Indexes Includes FollowSymLinks MultiViews
#AllowOverride AuthConfig FileInfo
#Order allow,deny
#Allow from all
#</Directory>

#<Directory "/CodeIgniter_1.6.1">
#Options FollowSymLinks
#AllowOverride FileInfo
#</Directory>

Any time I tried uncommenting a whole block, the entire website went down. Needless to say, I'm doing something wrong, but I am unsure what.

Are you trying to put the <Directory> directive inside of .htaccess? If so you'll get a 500 error every time, it needs to go in your httpd.conf. See http://httpd.apache.org/docs/1.3/mod/cor...#directory.

Quote:Step 5) Restart apache.

There is probably a way for me to do this, even with the command line. However, I am unsure of how yet.

You'll need the httpd command. I'd suggest typing "man httpd" at the command prompt and reading the man page.

I would strongly suggest NOT doing your development on the live server. Download XAMPP and get everything working on your development machine before you try to get it working on the live server. That will allow you to troubleshoot and learn how to do all this stuff without causing your site to go down. Once you're ready to test it on your live site, upload and test.. but not till you've played around on your local environment first.

HTH,

Brady
#5

[eluser]wolfman2000[/eluser]
...maybe I'm not being clear here. I do NOT have full control. I can't sudo bash my way in. Now I've just been "reported". I do not have access to httpd.conf, wherever that is.

Is there some alternate method that can be done?
#6

[eluser]bradym[/eluser]
If you don't have access to turn on mod_rewrite yourself, you'll need to have the server admin do it for you. There's simply no way around that.

Brady
#7

[eluser]wolfman2000[/eluser]
I have restored config.php and .htaccess to what they were previously. However, this still leaves the initial problem I had.

I am unable to visit http://www.pumpproedits.com/CodeIgniter_1.6.1/index.php directly. I have to visit http://www.pumpproedits.com/CodeIgniter_...hp/welcome in order to get my welcome page. Is there some other option I have to set up? If the CodeIgniter install was actually placed directly in the www folder and not one level down, would it just work?

PS: I managed to get XAMPP up and running. It took awhile since I forgot I had another mysql install up and running, but it's since been killed.
#8

[eluser]garymardell[/eluser]
Yes just take all the files out of the codeigniter_1.6.1 and stick them in the root folder (i guess www in your case)
#9

[eluser]wolfman2000[/eluser]
[quote author="gazza" date="1207446094"]Yes just take all the files out of the codeigniter_1.6.1 and stick them in the root folder (i guess www in your case)[/quote]
...that simple, huh? Looks like I'll have to do some development on XAMPP then. I at least have that set up, and my databases are all ported over.

I'll see if there was a way to host CodeIgnitor in a subfolder on my own time. For now...time to program and see what I can come up with.




Theme © iAndrew 2016 - Forum software by © MyBB