CodeIgniter Forums

Full Version: CodeIgniter homepage URL won't work with GoDaddy?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ErinKabbash[/eluser]
First of all thanks in advanced for any help that you can provide me with this. I am publishing a site that I made on to a GoDaddy server but the home page will not load? I read this post: Solution Found - Puzzled using codeigniter on godaddy shared hosting server but it doesn't resolve my issue. My links work properly it is just my homepage/default url that will not load. The site is theworksplumbingsd.com which will not load I have to put in theworksplumbingsd.com/home in order for the site to load. How come the theworksplumbingsd.com won't work but the theworksplumbingsd.com/home or any other link on the site will work?

This is what I have in my config.php:

Code:
$config['base_url'] = 'http://theworksplumbingsd.com';
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";

This is what I have in my routes.php:

Code:
$route['default_controller'] = "theWorksPlumbingController";
$route['404_override'] = '';
$route['home'] = 'theWorksPlumbingController/home';
$route['about'] = 'theWorksPlumbingController/about';
$route['services'] = 'theWorksPlumbingController/services';
$route['rates'] = 'theWorksPlumbingController/rates';
$route['specials'] = 'theWorksPlumbingController/specials';
$route['contact'] = 'theWorksPlumbingController/contact';

and this is what I have in my controller theWorksPlumbingController.php:

Code:
class TheWorksPlumbingController extends CI_Controller {

    public function index(){

        $this->load->view('templates/header');
        $this->load->view('home');
        $this->load->view('templates/footer');
    }

    public function home(){

        $this->load->view('templates/header');
        $this->load->view('home');
        $this->load->view('templates/footer');
    }

    public function about(){

        $this->load->view('templates/header');
        $this->load->view('about');
        $this->load->view('templates/footer');
    }

    public function services(){

        $this->load->view('templates/header');
        $this->load->view('services');
        $this->load->view('templates/footer');
    }

    public function rates(){

        $this->load->view('templates/header');
        $this->load->view('rates');
        $this->load->view('templates/footer');
    }

    public function specials(){

        $this->load->view('templates/header');
        $this->load->view('specials');
        $this->load->view('templates/footer');
    }

    public function contact(){

        $this->load->view('templates/header');
        $this->load->view('contact');
        $this->load->view('templates/footer');
    }
}

and this is my .htaccess(also my .htaccess is in the root folder):

Code:
# Options
Options -Multiviews
Options +FollowSymLinks

#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /

#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)

RewriteRule ^(.*)$ index.php?/$1 [L]

Thanks again so much for the help!

El Forum

[eluser]Aken[/eluser]
I'd suggest eliminating the use of capitals in your controllers. Chances are it's an issue with either A) the filename of your controller, or B) the instantiation of the controller's class.

Give your controller's class a simple name, like Pages (you don't need to add "Controller" to the class name -- read about how CI's URLs work and how the URI segments map directly to controllers and methods). Then, EVERYWHERE except the class name itself ("class Pages extends CI_Controller") should be lowercase, including the file name.

The error is being generated by CI, so it's not an issue with the index.php file not being found or anything. Simplifying your names and code should help a lot.

El Forum

[eluser]ErinKabbash[/eluser]
Aken!!!!!!!!!!!!!!!!!!! You're the freaking man!! Changing the Controller name worked like a charm. Little confusing to have the file names and everywhere else lowercase then only in the class capitalizing it. I was banging my head against the wall for a few hours there. THANK YOU!!! I owe you a beer sir.

El Forum

[eluser]Aken[/eluser]
Yeah, CI isn't exactly consistent with naming conventions and whatnot. You get used to it after using it for a while. Glad it worked.

To give you an unrelated hint, there's a way you could drastically reduce the amount of code you use so far. You could set a single route for each page, and point it to a single controller method:

Code:
$route['(home|about|services|rates|specials|contact)'] = 'pages/view/$1';

Then, your single controller method will load the appropriate view based on the parameter passed as $1, which will be one of the pages in the list.

Code:
class Pages extends CI_Controller {

function view($page)
{
  $this->load->view('templates/header');
  $this->load->view($page);
  $this->load->view('templates/footer');
}
}

Note that this is really basic, and you probably should add some code to check if the page is valid (like if the view exists, for example). But the goal is to not repeat yourself if you don't have to.