Part of the EllisLab Network
   
 
404 Errors on production server? But works locally… {Solution found}
Posted: 30 November 2006 09:14 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

Hi, a site which has been working completely fine locally (in CI 1.5.0.1)  is failing on my host’s server unexpectedly.

I’m using htaccess to remove the index.php and rewrites are working, but only my default controller loads. If I follow a link to my controllers (which use anchor() btw) i get 404 errors…even following a link to the default controller fails

My base_url() is producing the correct path:

http://www.mysite.com.au/dev/

And here’s my htaccess (which resides in the http://www.mysite.com.au/dev directory along side my CI installation):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase
/dev/
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>

Thanks for any assistance!

Profile
 
 
Posted: 30 November 2006 09:31 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

No prob, let’s see if we can’t get that working for you.  Just a few quick questions. (1) what is the base_url in your config file? (2) does it work without the htaccess stuff?

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 30 November 2006 11:40 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

Thanks Derek, this is causing unneeded stress :/

(1) base url in config:

$config['base_url']= "http://www.mysite.com.au/dev/";

(2) htaccess is creating the following rewrite for example:

The requested URL /dev/index.php/home was not found on this server.

Profile
 
 
Posted: 01 December 2006 07:03 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1740
Joined  06-23-2006

It sure sounds like your production server doesn’t support “url walkback”, or whatever the feature is that allows the segment-based technique to work. It’s an Apache configuration option, but I don’t recall the name at this time.

You might want to consult with your hosting company about this.

 Signature 

Mac OS X 10.4.10, Apache 1.3.3, PHP 5.2.3, CodeIgniter 1.5.x., baby!

Profile
 
 
Posted: 01 December 2006 07:05 AM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

OK, I’m assuming “http://www.mysite.com.au/dev/” is actually correct then and that this is not yet live?

does it work without the htaccess stuff?

edit: paste some code so that we can try it on our setups.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 01 December 2006 07:26 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1740
Joined  06-23-2006

Read this:

Troubleshooting page here

 Signature 

Mac OS X 10.4.10, Apache 1.3.3, PHP 5.2.3, CodeIgniter 1.5.x., baby!

Profile
 
 
Posted: 01 December 2006 09:35 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

@coolfactor: Ok, I’ve never heard of this “url_walkback”, but i’ll check with my host…

@Derek: Thats just a fictional name for the site, but all the same, the real site is within a subdir called dev. The real site can be located at: http://www.trv.org.au/dev/  . And no the site doesnt even work without the htaccess.

Here’s some sample code to try out (like i said before it is working on my very own setup)


trv/controllers/home.php

<?php

class Home extends Controller {

    
var $template;
    
    function
Home(){
        parent
::Controller();
        
    
}
    
    
function index(){
    
        $this
->template['title'] = 'Home';
        
$this->template['description'] = 'Welcome to Target Rifle Victoria';
        
$this->template['keywords'] = 'trv, target rifle victoria, target shooting, tra, target rifle australia';
        
$this->template['content'] = $this->load->view('front/home/home_view', NULL, true);
        
        
$this->load->view('front/main_view', $this->template);
        
    
}
    
    
}


?>


trv/views/front/home/home_view.php

<h2>Welcome</h2>
<
p>Target Rifle Victoria TRV is the governing body for small bore and air rifle shooting in Victoria.</p>
<
p>If you have never tried out the sport we encourage you to find out more about what the sport can offer you - friendship, a chance to compete equally, and the opportunity to participate in events across the state.</p>
<
p>We are affiliated with our national body, Target Rifle Australia, and you can therefore compete at events interstate.</p>
<
p>For those with even more ambition, our affiliation through the Australian Shooting Association provides a pathway to the Olympic and Commonwealth Games.</p>

trv/view/front/main_view.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title><?='TRV | '.$title?></title>
<
link rel="icon" href="<?=base_url()?>favicon.ico" />
<
link rel="shortcut icon" href="<?=base_url()?>favicon.ico" />
<
style type="text/css" media="all">
<!--
@
import "<?=base_url()?>css/style.css";
-->
</
style>
</
head>

<
body>
<
div id="wrapper">
    <
div id="banner">
        <
h1>Target Rifle Victoria (TRV)</h1>
    </
div>
    <
div id="mainmenu">
        <
ul>
            <
li><?=anchor('home', 'Home')?></li>
            <
li><?=anchor('about_us', 'About Us')?>
                
<ul>
                    <
li><?=anchor('about_us/membership','Membership')?></li>
                </
ul>
            </
li>
            <
li><?=anchor('try_it_out', 'Try it out!')?>
                
<ul>
                    <
li><?=anchor('try_it_out/safety','Safety')?></li>
                    <
li><?=anchor('try_it_out/how_do_i_get_involved','How do I get involved?')?></li>
                </
ul>
            </
li>
            <
li><?=anchor('calendar', 'Calendar')?></li>
            <
li><?=anchor('competitions', 'Competitions')?>
                
<ul>
                    <
li><?=anchor('competitions/flyers','Flyers &amp; Forms')?></li>
                    <
li><?=anchor('competitions/results','Results')?></li>
                </
ul>
            </
li>
            <
li><?=anchor('media', 'Media')?></li>
            <
li><?=anchor('clubs', 'Clubs')?></li>
            <
li><?=anchor('contact_us', 'Contact Us')?></li>
        </
ul>
    </
div>
    <
div id="content">
        <
div id="right">
            
<?=isset($submenu) ? $submenu : ''?>
        
</div>
        <
div id="left">
            
<?=$content?>
        
</div>
    <
div class="clearer"></div>
    </
div>
    <
div id="footer">
        <
p>&copy;Target Rifle Victoria (TRV) 2006. Designed and maintained by Richard Lee.</p>
    </
div>
</
div>
    
</
div>
</
body>
</
html>

Profile
 
 
Posted: 01 December 2006 09:36 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006
coolfactor - 01 December 2006 07:26 AM

Read this:

Troubleshooting page here

Coolfactor, I’ll have a crack at this troubleshooting section too..

Appreciate your help guys

Profile
 
 
Posted: 01 December 2006 09:48 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

Ok so I added the ‘?’ to my config as indicated in the troubleshoot page and now it works (?) I’m ok with this but its a bit of annoyance, it must be this url walking thing i guess


$config['index_page'] = "?";

Profile
 
 
Posted: 01 December 2006 10:35 AM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

Good catch Coolfactor!  Glad it got resolved rlee.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 12 December 2006 08:12 PM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

Hi guys,

further my post I have made a wiki entry http://www.codeigniter.com/wiki/Server_URL_problems/

Profile
 
 
Posted: 12 December 2006 08:45 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  486
Joined  09-14-2006

If the server is using the cgi version of PHP, there can also be problems with PATH_INFO not being set. It can be worked around by manually setting $_SERVER[‘PATH_INFO’] in the index.php file. More details here: http://codeigniter.com/forums/viewthread/47083/

 Signature 

Code Igniter 1.5.4 / CentOS 5 / PHP 5.2.3 / Apache 2.2.2 / MySQL 5.0.27

Profile
 
 
Posted: 12 December 2006 10:05 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  147
Joined  09-24-2006

Hi Joeles, yeah I checked my phpinfo() and it doesn’t appear to be running in CGI mode, unless “API: Apache 2.0 Filter” is in fact CGI mode??

FYI I updated my Wiki entry

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: 66432 Total Logged-in Users: 32
Total Topics: 84799 Total Anonymous Users: 1
Total Replies: 455094 Total Guests: 225
Total Posts: 539893    
Members ( View Memberlist )
Newest Members:  GlennJHurlyBurlyDylan1978X_franbaguasllogocsaturkeyPeter BryanttherendStudioGeorgiaJ