Part of the EllisLab Network
   
 
codeigniter site upload
Posted: 18 July 2008 09:57 AM   [ Ignore ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

I am going to be uploading a codeigniter site to 1and1 hosting.  I am using an .htaccess file, database, and i have mod_rewrite on.  Is their any precautions I should take, things to do, things to avoid when doing this?  I want it to go as smoothly as possible.  This is a new site for an old regular html site so I am uploading the new site to a different folder so I can test it before going live.  Is this going to be a problem considering the codeigniter site will not be at the root level of the directory?

Profile
 
 
Posted: 18 July 2008 02:07 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  491
Joined  02-21-2007

Be sure to correctly set the base_url item in the config, and the database settings too.

Profile
 
 
Posted: 18 July 2008 04:05 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  674
Joined  02-05-2007
bennyhill - 18 July 2008 09:57 AM

...Is this going to be a problem considering the codeigniter site will not be at the root level of the directory?

Not a problem, in the .htaccess just make sure you set the rewritebase to “/your_subdir”.

In addition to what Grahack mentioned, you may have to change your system and application roots in the index.php file if they were hard-coded. Also, If you are moving from Windows to Linux, just be aware that Linux is case-sensitive. That can cause problems if you didn’t follow the CI naming conventions carefully.

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 19 July 2008 12:34 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

Well I have a web host with a url..lets say www.mysite.com for demo purposes

I have uploaded my codeigniter application to a folder

www.mysite.com/site/

to test it before going live on www.mysite.com

My htaccess folder reads like this

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

what should I change this to in order for my site to work withing www.mysite.com/site/
folder?

In my config file I have

$config[’base_url’] = “http://www.mysite.com/site/”;

But I get a 404 not found error when I test in a browser by typing www.mysite.com/site into the address bar.

What am I missing or doing wrong?

Profile
 
 
Posted: 19 July 2008 12:43 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  674
Joined  02-05-2007

I’ve already answered that question above - use RewriteBase. Here it is again spelled out:

RewriteEngine On
RewriteBase
/site

RewriteCond
%{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^(.*)$ index.php/$1 [L]

BTW, use either

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d

or

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)

but not both.

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 19 July 2008 12:47 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

Yes I tried that but I still get a 404 error

Profile
 
 
Posted: 19 July 2008 01:05 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  674
Joined  02-05-2007

I don’t see the RewriteBase in your .htaccess above.

To debug this, get the site working without the .htaccess file. Remove it and access your site with the index.php in the url (http://www.mysite.com/site/index.php). Make sure your index page is defined in config.php ($config[’index_page’] = “index.php”;). If that works, then you know that you’re doing something wrong in the .htaccess file. For example, some hosts require a “?” after the index.php.

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 19 July 2008 08:45 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

Well I took the bare codeigniter framework (from zip file), edited the base_url in the config file and uploaded to my host server. I uploaded it to a folder called “test” and I got a 404 error.  Now when I upload that same application, change the base url accordingly and upload it to the ROOT it works. 

Now why can’t I run a codeigniter application from a folder that is not the ROOT?  Is this a problem with the framework? Does it have to to with the code in the index.php file that attempts to set get the server path and set the constants?

Profile
 
 
Posted: 19 July 2008 11:16 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

Well it was a dumb oversight.  In the config/database.php file I had “mysqli” as the db driver.  I changed it to “mysql” and everything worked as it should.  Thanks for the help on the .htaccess file guys.

Profile
 
 
Posted: 20 July 2008 10:05 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

Spoke too soon.  The site is running from the subdirectoy ok but I had to delete the htaccess file and add index.php/ to all my links in my code.  I tried again to get the htaccess to work this morning but it still keeps resulting in 404 errors.

In a subdirectory called “newsite” I have my index.php file, htaccess file, and the codeigniter folder.
I want to be able to type www.mysite/newsite/ in the address bar and get my default controller to load.

What do I have to do to get this to work?

Profile
 
 
Posted: 20 July 2008 12:31 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  674
Joined  02-05-2007
bennyhill - 20 July 2008 10:05 AM

Spoke too soon.  The site is running from the subdirectoy ok but I had to delete the htaccess file and add index.php/ to all my links in my code.  I tried again to get the htaccess to work this morning but it still keeps resulting in 404 errors.

In a subdirectory called “newsite” I have my index.php file, htaccess file, and the codeigniter folder.
I want to be able to type www.mysite/newsite/ in the address bar and get my default controller to load.

What do I have to do to get this to work?

We know nothing about your .htaccess or config.php files. For example, if you’re using .htaccess to remove index.php from your urls, you must set $config[’index_page’] = “”;. You shouldn’t be hard-coding “index/” in your urls. Use base_url instead.

Reread the user guide and then have another look through this thread.

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 22 July 2008 06:46 AM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  29
Joined  05-11-2008

After some major digging, I guess I needed “Options -MultiViews” in my .htaccess file according to 1and1.com faq.

I now have the codeigniter application successfully running from my subdirectory the way it should be without hard-coded “index.php”

I also needed “DirectoryIndex index.php/” in there to get this url to work: www.mysite.com/newsite/
As well as another htaccess file in the root that directed apache to parse all files with .php extension to parse as php5 and not php4.

This little subtleties may be local to 1and1.com so I posted to maybe help someone else.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 61059 Total Logged-in Users: 22
Total Topics: 73867 Total Anonymous Users: 1
Total Replies: 398463 Total Guests: 332
Total Posts: 472330    
Members ( View Memberlist )
Newest Members:  bnolenstanjadebieSan2kakifemreSchottec2kmeenazterjinFuadgeorge_k_allis