Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issue with new view working in development but coming up with error 404 when made live
  • I created a new view for a page and it works fine in my sandbox but when I pushed the code to the ec2 instance the link now gives me a 404 error.  I edited routes to include it initially but it gave me the 404 error in my test environment so I removed it.  I have :

    "wtools" => array (
                "wtools" => array("read")
            ),

    in my simpleauth.php

    my link is:

    <div id="boxmain" class="unhidden" onclick="location.href='/index.php/wtools'">
                    
                    <a style="color:black;" target="_blank">
                        <div class="glyphicon glyphicon-signal" style="margin-left:10px;"></div>
                        <strong>Wireless Tools</strong>
                    </a>              
            </div>

    in dashboard.php

    wtools.php is located in apppath/views/welcome/ and the controller contains:

    public function action_index()
    {
    $this->template->title = "Wireless Tools";
    $this->template->breadcrumb = array("Wireless Tools");
    $this->template->content = View::forge('welcome/wtools');
    }

    any help would be greatly appreciated.

    Thanks
  • As a side note, the 404 error is coming from fuel and I have no other problems with any of the other views that I have created so I know its not a rewrite rule or apache problem.  There has to be something different in either the way I created this one or something I should do different because this is a link on the page rather that in the nav bar but I can't seem to find it.
  • I also noticed that I am getting a "no access: welcome.[read]" error when trying on a samsung tablet
  • eh, views don't contain methods?

    You mean you have a controller Controller_Wtools in wtools.php in app/classes/controller?
  • yes the code clip is from wtools.php in app/classes/controller

    class Controller_Wtools extends Controller_Auth
    {

    public $template = 'index';
            
            public function before()
    {
    parent::before();
    }

    public function after($response)
    {
    $response = parent::after($response);

    return $response;
    }

    /**
    * The Wireless Tools Link message
    *
    */
    public function action_index()
    {

    $this->template->title = "Wireless Tools";
    $this->template->breadcrumb = array("Wireless Tools");
                    $this->template->user = Session::get('username', false);

    $this->template->content = View::forge('welcome/wtools');
    }
    }

  • Ok, then providing you don't have any routing that blocks access to this contoller, /wtools or /wtools/index shouold just work.

    There is nothing in your Controller_Auth that throws a NonFoundException? If not, I don't see any reason why it would give a 404.

    Are you using the standard .htaccess on your live server, or did you construct something yourself? If your rewrite rules are wrong, it can also lead to incorrect requests. Which brings me to the question of why you use index.php in your URL's. Don't you rewrite them?
  • Its just the standard .htaccess and it works for everything else so I am inclined to think its not.. I checked to ensure that the local .htaccess is the same as the one on the instance and there are no differences.  There is nothing in Controller_Auth that throws an exception.  I am gonna post my routes.php because I did alter it today in my attempts to fix the issue.  I added the "'welcome/(:any)' => 'welcome/$1',".  The wtools.php is in views/welcome/

    <?php
    return array(
    '_root_'  => 'welcome/dashboard',  // The default route
    '_404_'   => 'welcome/404',    // The main 404 route

    'dashboard' => 'welcome/dashboard',
    'home' => 'welcome/home',
            'welcome/(:any)' => 'welcome/$1',
            
    'logout' => 'session/logout',

    'changelocation/first' => 'changelocation/first',
    'changelocation/(:any)' => 'changelocation/index/$1',

    'authorize' => 'exempt/index',

    'support' => 'support/index',

    'free' => 'supportbasic/home',
    'free/general' => 'supportbasic/general',
    'free/(:any)' => 'supportbasic/index/$1',
    'supportbasic/general' => 'supportbasic/general',
    'supportbasic/(:any)' => 'supportbasic/index/$1',
    'supportbasic' => 'supportbasic/general',
    'help' => 'welcome/help',

    'api/bandwidth' => 'bandwidth/index'
    );
  • HarroHarro
    Accepted Answer
    You keep confusing me.

    The location of the view is not relevant, the location of the controller, and the code in it is. Missing views don't generate a 404, missing controllers do. Also, the name/location of the view isn't relevant, your request goes to a controller action.

    So I don't understand why you add routes for 'welcome', if your controller is called Controller_Wtools? There is no "welcome" in the controller name, nor the method name?
  • Ok, so I figured out the problem. I had failed to add the new files to the repo so they were never pushed.  As soon as I did that my problem was fixed.  I knew it had to be a silly stupid error of my own but I was failing to check my steps involving more than just the code.  Thanks for your time and sorry for any inconvenience.


  • No problem, glad you've got it sorted.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion