Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
404 when going anywhere but index
  • Hi everyone,
    Having a little routing problem and I reckon its something to do with my htaccess file but I cant seem to fix it.

    Basically I have my domain pointing to the public folder so thats sorted and that works fine in loading index but if I try to go to mysite.com/controller/function then it wont work. it will work fine on my local windows machine though!.

    The server is running on ubuntu with a clean install and the latest apache and php, I have mod_rewrite enabled and the error it gives me is just a plain old 404  (not fuels fancy 404 page).
    However if I go to the ip/directory/public/index.php?controller/function then I do get fuels fancy 404 page.

    Here is whats in my .htaccess, I have played around with many variations of this and it still doesnt work :/
    <IfModule mod_rewrite.c>

    Options +FollowSymLinks -Indexes
    RewriteEngine on
    AllowOverride All
    RewriteBase /sitename/public


        RewriteRule ^(/)?$ index.php/$1 [L]
        RewriteCond %&#123;REQUEST_FILENAME} !-f
        RewriteCond %&#123;REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

  • Why have you replaced the .htaccess that is part of the framework distribution by your own version?

    Chances are your hoster doesn't use a plain vanilla apache setup, but uses nginx, php-fpm, or some cgi version.

    All of them requiring different rewrite rules, and all of them supported out of the box by Fuel.  But not by your rules.
  • The standard .htaccess file wasnt working and someone with the same issue as me fixed it with the .htaccess, however that didnt fix it for me. I have returned the .htaccess to its original form as changing the rewrite base etc... wasnt working.

    It is a plain vanilla apache setup as I set it up myself on a fresh linode vps running ubuntu 10.04 LTS
  • Also to clarify how I transferred the data to the server, I put the whole project onto my private git repo, cloned it to the server and ran php oil refine install and I did a composer update.

    As of now the app is just loading in static pages and is not interfacing with a database.
  • Why would you need a Rewritebase? If you control the webserver yourself, set the virtualhost documentroot to the public folder, and off you go?

    Non standard setups will lead to complicated rewrite rules, which you should avoid at all costs, and since you control the setup, you can.
  • Yeah thats what I have done and that usually works, just have apache pointing my domain to the public folder however when that didnt work thats when I started messing with the .htaccess as thats the first thing I thought of.

    I never used to have a problem with any of this however iv just come back to using fuel after about a year of using Yii at my work so im a tad rusty with the framework. However I don't remember ever coming across this issue before and as its a fresh install I wouldnt have expected it.
  • I wouldn't know why it doesn't work either. We deploy on a daily basis, and I've never seen the default htaccess not to work...
  • Ah well I suppose this was the push I needed to upgrade to laravel.
  • Laravel uses exactly the same rewriting rules, so if you think that is the solution, by all means.

    If you get an Apache 404 error and not a Fuel one, it means your request doesn't even get to Fuel, so you need to debug the Apache setup. Are the rules processed at all? Error messages in the webserver logs?

    Switching to Laravel is not going to solve it.
  • <VirtualHost *:80>
            ServerName mysite.name
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/mysite/public

            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

    This is my config for the site, iv kept it very simple, as I said it is a fresh LAMP install with the latest php version and mod_rewrite has been enabled.

    I don't know where else to go with this as apache isnt picking any errors up and it works fine locally.

    Im going to start a fresh fuel installation and report back on that.

  • Yeah I have done a clean install and again the welcome page loads however if I go to site.com/welcome/index then I get an apache 404. 
  • Ahhhhhhh you were right buddy :), I had to add AllowOverride all to my vhosts file... Frustration over! 

    Hopefully this helps some other people making the same mistake.
  • Cool! Glad you've got the problem sorted.

Howdy, Stranger!

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

In this Discussion