Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing
  • Hi, Im having a routing problem. Fresh install of Fuel. I'd like the URl [url=http://localhost/blog/admin/]http://localhost/blog/admin/[/url] to link to the dashboard.
    I've tried modifying routes.php like this:
    <?php
    return array(
     '_root_'  => 'welcome/index',  // The default route
     '_404_'   => 'welcome/404',    // The main 404 route
     
     'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
     'admin' => 'admin/dashboard',
    );
    

    I can access the dashboard with [url=http://localhost/blog/index.php/admin/]http://localhost/blog/index.php/admin/[/url] I've been on this for hours now.
    THanks for any help
  • On my linux install, in my app/config/config.php file, I had to change...
      /* Set this to false or remove if you using mod_rewrite.
      */
     'index_file'  => 'index.php',
    
    to
    'index_file'  => '',
    

    in order to remove that from the url. Hope that helps!
  • I setup a default build of FuelPHP 1.2.1 making the public folder as the live docroot. I was having the same problem on Mac OSX, however I added:
    RewriteBase /
    

    To my .htaccess file which fixed the issue. Full .htacess file contents:
    <IfModule mod_rewrite.c>
        RewriteEngine on
      # ADDED TO MAKE index.php REMOVAL FUNCTION
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    
    Hope this helps.
  • Ok, I've done all you said. The folders are correct, I still access my website properly with http://www.example.dev. There are no capitals in the folder names. But to access the admin I still require index.php/admin I've added to routes.php:
    'admin' => 'admin/dashboard/' ,
    
  • If it works when using the full URL (with index.php), it's not a FuelPHP issue. It is most likely your rewrites that need to be defined properly, which is always going to be a bit of a challenge when you install FuelPHP is a subfolder of your document root.
  • OK thank you, Could you show me what you think I need to do?
    Do I need a .htaccess file? Or keep trying with the routes.php file?
  • You can not remove the index.php from the URL using routes, routes are only effective for the part after index.php. You need rewrite rules, either in your webserver configuration or in a .htaccess file. It is difficult to tell you exactly what to do, as it depends on your folder structure, and what else you have running in the docroot. The default FuelPHP installation is not made to be installed in the docroot, the public folder should be your docroot. In that case, the .htaccess that is part of the distribution works fine. It is better to setup a second virtualhost for your fuel installation, instead of trying to come up with a working rewrite in a docroot that contains all kinds of stuff next to a FuelPHP installation. Added benefit is that you will get rid of the 'localhost' name, which is something you shouldn't use, a name without a dot is illegal according to the RFC, and will lead to problems with cookies and sessions...
  • Then your rewriting doesn't work. Are you using an FCGI install by any chance?
  • ok thanks, I've setup a virtual host so I know access my website via: http://www.example.dev I still require index.php/admin to show my dashboard. I've also moved my fuel folder up so I now have:
    www
        fuel
            App
            Core
            Packages
        Example
            index.php
    
    What should I do from there?
  • I hope you didn't use capital letters for your folders like in your example. All folder names in a FuelPHP installation should be lower case. And you are still deviating from the suggested FuelPHP installation. 1. Create a virtual host definition
    2. In that, define the DocRoot as /some/local/dir/fuel/public
    3. Install the FuelPHP folder tree in /some/local/dir/fuel (this means index.php is in the public folder)
    4. Start your browser and it works I can't make it any easier than this...

Howdy, Stranger!

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

In this Discussion