• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running CodeIgniter from Subfolder on Godaddy

#1
[eluser]yorgo[/eluser]
I've read a bunch of the forums on this subject, but none have seemed to solve my problem.

I have a domain on Godaddy with a simple index.html file at the root displaying a splash page. I have CI installed in a subfolder, from where I would like to run it from.

Folder structure:
/
- index.html
- ci
- index.php (CI's index.php file)
- .htaccess
- ... (the rest of CI's core files/directories)

The contents of my htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

My config settings:
$config['base_url'] = 'http://www.mydomain.com/ci/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

I tried following the path of execution and it seems to be failing in Router.php, when setting the default controller. Router.php has a _validate_request function with parameter $segments. When $segments is set to array("index","index") it fails on the second IF statement, if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)), and continues to the 404 page. The same value for the parameter on my local machine does not fail. When I change the IF statement to uppercase the first letter in $segments[0], so Index instead of index, the IF statement does not fail, but I get an error page saying, "Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid."

I may be chasing a wild goose here and the problem may just lie in my htaccess file.

Any ideas anyone?

Thanks in advance.

#2
[eluser]InsiteFX[/eluser]
You need to change the index.php file to point to the correct directories for $system_path and $application_folder

InsiteFX

#3
[eluser]yorgo[/eluser]
I believe $system_path and $application_folder are correctly set. Otherwise I wouldn't be getting as far as I am.

In the IF statement I mentioned 'if (file_exists(APPPATH.‘controllers/’.$segments[0].EXT))' the expression evaluates to 'if (file_exists(APPPATH.'controllers/index.php'))' which is where it fails.

Changing the file name to Index.php passes (with the capital I). Giving me more assurance in the integrity of the path names.

I'm wondering if it has to do with the htaccess file or a PHP setting that I'm not aware of?

Any other ideas?

#4
[eluser]toopay[/eluser]
put trailing slash at rewritebase and include your subfoolder on rewrite rule
Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /ci/
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ ci/index.php?/$1 [L]
  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ ci/index.php?/$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ci/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
  ErrorDocument 404 ci/index.php
</IfModule>

#5
[eluser]yorgo[/eluser]
Nope...

I'm testing locally on my Mac (10.6), PHP 5.3.3. The site is hosted at GoDaddy on a Linux box with PHP 5.2.17.

Locally I can change the require statement of the CodeIgnitor core (in the bottom of index.php) from:
require_once BASEPATH.'core/CodeIgniter'.EXT;
to
require_once BASEPATH.'core/codeigniter'.EXT;
and everything works fine.

Changing this on GoDaddy's environment kills the app with a PHP warning (failed to open stream).

Maybe I should contact GoDaddy??

#6
[eluser]toopay[/eluser]
Missread this thread. So its accesible, but the loader class failed?

#7
[eluser]yorgo[/eluser]
Is it the loader class? Not sure what to think at this point.

I would have figured anyone setting up a CI app on GoDaddy would have run into this issue.

#8
[eluser]toopay[/eluser]
I'm still not clear, since you start this thread by pointing to some CI core class function rather than describe your issues. So, what is exactly your issue?

#9
[eluser]yorgo[/eluser]
The issue is I get a 404 no matter what url I point to.

#10
[eluser]toopay[/eluser]
404 CI or apache?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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