Welcome Guest, Not a member yet? Register   Sign In
Apache 2.2.10 PHP 5.3.6 UBUNTU 11.10 and Codeigniter 2.1.0
#1

[eluser]Unknown[/eluser]
I've dealt with codeigniter for over 3 years now. I have code working in 1.7 , 2.0 and 2.1.
Recently I decided to upgrade my server to ubuntu 11.10. Upgrade was made on a clean hdd, so it is a completely new machine. I started transferring my old code (1.7 and 2.0) and noticed that i get 404 not found errors when I try to access URLs that are different than the default. So lets say, my site resided on example.com.
Going to
Code:
http://example.com
the default controller gets loaded,
but trying to access
Code:
http://example.com/second_controller
, returns with 404 error. At first I thought it was .htaccess error, and that my mod rewrite wasn't active. This wasn't the case. mod_rewrite is active, also I have AllowOverride all in my site config. But just to be sure I tried putting something like
Code:
RewriteRule .* http://codeigniter.com/ [L,R]

just to see if it gets redirected. And it works. I hacked around the code for a while thinking that the issues are there ( trying to find a problem in the older codeigniter versions). Then I decided that I really can't be sure with one of my sites and I need to download a fresh codeigniter. I downloaded the latest version 2.1.0. I put it on the server, made a quick setup in the config (set the base url). Created a quick controller second_controller(a copy of the default controller).And tried it, fresh from the oven without even messing with .htaccess. I tried
Code:
http://example.com
(with codeigniter 2.1) it gave me the default controller. tried
Code:
http://example.com/index.php/second_controller
and it showed me the 404 ERROR. Ok so I guess codeigniter 2.1.0 doesn't work. To prove that. Copied that same code to a server that I have that runs on Debian 6 with Apache 2.1.16. EVERYTHING WORKED FINE.
http://debian_server_example.com/index.p...controller showed the second controller.?????. Just to test things more, went to a server with ubuntu 9.04 and tried it there. WORKED AGAIN. And to be on the safe side, went even further and put it on ubuntu 8.04 (which is pretty much ancient by now) . Worked fine there too.

Played a bit on the forum and google. Found some people having similar issues, but nobody answered them. Some of the suggestions in the answers were to play with the
Code:
$config['uri_protocol'] = 'AUTO';
and try one of the other possibilities
Code:
| 'PATH_INFO'  Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI'  Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
. Tried them all . Didn't work. I don't usually have to ask on forums, cause the problems I have are usually answered somewhere on google. But this one isn't. Anyone have any ideas? Thanks in advance.
#2

[eluser]Kyle Johnson[/eluser]
I just recently migrated my .htaccess files into the actual .conf for my site, so give this a shot and see if it helps.

Code:
ServerName example.com
DocumentRoot /var/www/public
<Directory /var/www/public>
DirectoryIndex index.php index.html
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride None
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^$ index.php/ [QSA,L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) index.php?/$1 [QSA,L]
</IfModule>
Order allow,deny
Allow from all
</Directory>

I also had some issues with the base_url and the index file giving me trouble when I did a redirect, so I implemented the changes here:
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
/* Detect ssl connectivity */
if ( isset($_SERVER['HTTPS']) )
$ssl = $_SERVER['HTTPS'];
elseif ( isset($_SERVER['HTTP_FRONT_END_HTTPS']) )
$ssl = $_SERVER['HTTP_FRONT_END_HTTPS'];
else
$ssl = "OFF";

$root = (stripos($ssl, "ON") !== FALSE) ? "https" : "http";

/* Many pages/apps served through the same domain */
if ( isset($_SERVER['HTTP_X_FORWARDED_HOST']) ) {
list($host) = explode(',', str_replace(' ', '', $_SERVER['HTTP_X_FORWARDED_HOST']));
} else {
$host = $_SERVER['HTTP_HOST'];
}

$root .= "://".$host;

if ( ! isset($_SERVER['ORIG_SCRIPT_NAME']) )
{
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
}
else
{
$root .= str_replace(basename($_SERVER['ORIG_SCRIPT_NAME']),"",$_SERVER['ORIG_SCRIPT_NAME']);
}

$config['base_url'] = "$root";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

Let me know if this works. I was going to make a 11.10 build last week, and now I'm glad I didn't.
#3

[eluser]allpointstech[/eluser]
Im having the same trouble with a base install of CI.

http://localhost/ci/
http://localhost/ci/index.php

Works and I get the welcome page.

http://localhost/ci/index.php/welcome/
http://localhost/ci/welcome

Both Fails with 404. It fails with any controller. But if I change the route of the default controller, it will load that controller when I go to http://localhost/ci/.

I put this on an windows XAMPP and it works fines. It seems to be Apache or PHP. I tried adding mod_rewrite, editing the php.ini and apache configs.. I'm stuck.
#4

[eluser]Unknown[/eluser]
[quote author="allpointstech" date="1332467026"]Im having the same trouble with a base install of CI.

http://localhost/ci/
http://localhost/ci/index.php

Works and I get the welcome page.

http://localhost/ci/index.php/welcome/
http://localhost/ci/welcome

Both Fails with 404. It fails with any controller. But if I change the route of the default controller, it will load that controller when I go to http://localhost/ci/.

I put this on an windows XAMPP and it works fines. It seems to be Apache or PHP. I tried adding mod_rewrite, editing the php.ini and apache configs.. I'm stuck.[/quote]

It happens the exactly same thing to me. Any clue?
#5

[eluser]allpointstech[/eluser]
I've tried a few things. The next thing I will try to create another ubuntu server from scratch following these instructions:

http://www.upubuntu.com/2011/09/how-to-i...mysql.html

I did do everything in the tutorial, but not in the exact order. I also did a bunch of extra things which i don't remember. The only thing I can think of is that I must have installed something or some update which which breaks it. So I will just run it from scratch again and see if it still happens.. Or else I'm going with an earlier version of everything.




Theme © iAndrew 2016 - Forum software by © MyBB