Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Assest throwing a 404
  • Hi, I just started to use Fuel and it looks like I can make everything work except the assets. I'm still devoloping localy so I installed Fuel in my document root. I added an extra .htaccess file to the application root and set the RewriteBase to /my-app/public I didn't touched the htaccess in the public folder. When I'm trying to call the Asset class inside a view:
    echo Asset::css('style.css') It return the following url and redirect to a 404:
    /my-app/assets/css/style.css But the correct url should be /my-app/public/assets/css/style.css I think I got a problem in the htaccess inside the public directory, which should handle request inside the public directory. Am I missing something? Thank you for any help. Document Root .htaccess
    <IfModule mod_rewrite.c>
    RewriteEngine on RewriteBase /my-app/public RewriteRule ^(/)?$ index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule> Public folder .htaccess
    <IfModule mod_rewrite.c>
    RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
  • So it is not installed in the document root, but in folder called 'my-app' in the document root? In that case you'll have to update the config, as the generated URL's need to be prefixed by 'my-app'.
    Set your base_url to '/my-app/', and Fuel will generate the correct URL's.
  • Harro Verton wrote on Friday 5th of August 2011:
    So it is not installed in the document root, but in folder called 'my-app' in the document root? In that case you'll have to update the config, as the generated URL's need to be prefixed by 'my-app'.
    Set your base_url to '/my-app/', and Fuel will generate the correct URL's.

    Sorry my bad. The app is in a folder inside doc root. However i set the base dir correctly because the controllers and views are working correctly.
  • The base_dir isn't involved in loading code, that works relative to the index.php, based on the paths you have defined in there. But for classes like Assets and Uri to generate the correct URI's (prefixed with /my-app/), the base_dir must be set correctly, as it will be prepended to any URI generated.
  • Harro Verton wrote on Sunday 7th of August 2011:
    The base_dir isn't involved in loading code, that works relative to the index.php, based on the paths you have defined in there. But for classes like Assets and Uri to generate the correct URI's (prefixed with /my-app/), the base_dir must be set correctly, as it will be prepended to any URI generated.

    Thanks. I set the base_dir to "/my-app/public/" and it's working.
  • Harro Verton wrote on Sunday 7th of August 2011:
    The base_dir isn't involved in loading code, that works relative to the index.php, based on the paths you have defined in there. But for classes like Assets and Uri to generate the correct URI's (prefixed with /my-app/), the base_dir must be set correctly, as it will be prepended to any URI generated.

    Thanks. I set the base_dir to "/my-app/public/" and it's working.
  • Dived into the code of the Asset class. Turns out that it doesn't use base_url directly, but through the asset config file. But it does use it.
    So it should work ok, unless you have changed the url setting in the asset config file.

Howdy, Stranger!

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

In this Discussion