0

I am trying to learn fuelPHP and I came form a CI background. I am using this tutorial so that I can familiarize myself on this.

http://net.tutsplus.com/tutorials/php/getting-started-with-the-fuel-php-framework/

My problem is in step 2. When I access my simple controller

http://localhost/fuel/public/index.php/hello 

I get a 404 error.

*fuel is the directory of this freshly installed fuelPHP on my localhost.

When I set this to be my default route, the controller works.

Did something change in the new version that prompted this?

Here is my .htaccess on the /public/ folder.

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Thanks.

Mr A
  • 1,345
  • 4
  • 22
  • 51
  • Have you got .htaccess set up? If so can you post the code? – Ben Swinburne Oct 23 '12 at 08:22
  • @BenSwinburne This is a fresh install. On /fuel/ there's no .htaccess /fuel/fuel/has .htaccess and it only contains deny all in it. But really, the default controller ... welcome.php was able to be access without any problems here. – Mr A Oct 23 '12 at 08:27
  • There should be one in /public/ as part of the default install but depending on your apache/php configuration you may need to tweak it. The reason the welcome controller works is because the route loads the correct page. It's the .htaccess which send the /hello bit off to index.php – Ben Swinburne Oct 23 '12 at 09:09
  • 1
    What about `http://localhost/fuel/public/index.php/hello/index`?(specifying the action name too). – Savageman Oct 23 '12 at 09:10
  • @BenSwinburne I will add the .htaccess on the /public/ folder. What should I add here? – Mr A Oct 23 '12 at 09:19
  • @MrA a .htaccess file comes with the Fuel download already in the public folder. However, depending on your configuration you might need to try [these](http://dev-docs.fuelphp.com/installation/troubleshooting.html#/404_install) tweaks. – Ben Swinburne Oct 23 '12 at 12:34
  • Could you show the `app/config/routes.php` file ? Step 2 is about creating your own controller, which mean adding routes (as mentioned in the tutorial). – Sherbrow Oct 23 '12 at 17:36

1 Answers1

1

You are making it very complicated for yourself by installing FuelPHP like this.

It has been designed in such a way that the 'public' folder is your webservers document root, which means all fuel stuff is outside your document root, and the .htaccess is directly inside your document root.

By not only installing it entirely inside your document root, but also in a subfolder of that document root, you need to modify your rewrite rules. Start by adding

RewriteBase /fuel/public

to the one in public, and see if that helps. Also, this .htaccess is made for "standard" apache type installations. If you run anything else you might need a different .htaccess. If you use fcgi for example, get the .htaccess from the 1.4/develop repo, it's more fault tolerant towards your webserver type.

Final remark: you should not use localhost as hostname. It's an illegal name in a lot of RFC's, one of them being the one that documents the use of cookies. You'll have all kinds of session issues with some browser (versions) if you use "localhost". Instead, setup virtual hosts (a better solution then subfolders anyway), and use a hostname like "mymachine.local".

WanWizard
  • 2,574
  • 15
  • 13