Welcome Guest, Not a member yet? Register   Sign In
weird issue with a controller
#1

[eluser]jblack199[/eluser]
I've got a site that I built, and i've put it on 2 different domains...

The first domain works fine... The second domain is having issues....

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *   http://example.com/index.php/welcome
  * - or -  
  *   http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://ellislab.com/codeigniter/user-guide/general/urls.html
  */

public function __construct()
       {
            parent::__construct();
   if (strlen($this->input->cookie('prospectId') >= 1)) {
    header("Location: http://www.domain.org/congratulations/");
   }
       }
    
public function index()
{
  $data['main_content'] = "home/index";
  $this->load->view('welcome_message', $data);
}

public function newProspect() {
  echo "yo!";
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.p

This is an example of my controller.... so when I go to:

http://www.domain.org it pulls up the index perfectly...

however when i go to http://www.domain.org/welcome/newProspect it still only pulls up the index() function instead...

but when i go to http://www.domain.org/index.php/welcome/newProspect it works.. even though I have htaccess in place to remove the index.php from the URL.. which looks like:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the 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]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

any ideas?
#2

[eluser]vbsaltydog[/eluser]
Are both sites on the same server? If not, does the non-working server have mod_rewrite enabled in Apache?
#3

[eluser]CroNiX[/eluser]
Not having to do with your problem, but those lines pertaining to the system and application directories in your htaccess are not needed. Those directories come stock with their own htaccess now.
#4

[eluser]jblack199[/eluser]
@vbsaltydog, no both are not on the same server.... I've written a quick test script to see if mod_rewrite is enabled in the system and mod_rewrite is definitely enabled in Apache.

Although I figured out what's going on i just have no clue how to fix it....

I uploaded a FRESH codeigniter installation into /test/ on the server...

http://domain.org/test/welcome/testing

so /test is the base path...
/welcome is the controller
/testing is the secondary function inside that controller

So when I create:

Code:
public function testing() {
echo "YEP";
}

and delete the index() function and go to http://www.domain.org/test/welcome/testing/ it gives me a 404 instead of what i'm expecting to see... SO it's seeing the controller just fine, but it's NOT seeing anything past the controller in the URL...
#5

[eluser]vbsaltydog[/eluser]
Try this:

Code:
public function testing() {
echo "YEP";
exit;
}
#6

[eluser]jblack199[/eluser]
Whats happening is its not even reading the testing() function at all... I did figure it out though perhaps you can shed some light into why this might be the case...

on the working server i have in my .htaccess like

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

but on this server that doesn't work so I changed it to:

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

and it works just fine...





Theme © iAndrew 2016 - Forum software by © MyBB