简体   繁体   中英

fuelPHP: Can't Access My Controllers Directly

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.

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM