Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
/public/ is present in url using Html::anchor
  • I'm trying to make a link to main page using:
    <code><?php echo Html::anchor('/', 'Mainpage') ?></code>
    But it returns link "http://website/public/";
    Then I went to change the base_url in config.php
    <code>base_url => null</code>
    to
    <code>base_url => 'http://website/'</code>;
    But it brokes my styles
    <code>href="http://website/assets/css/reset.css?1345553804"</code>;
    The path should be
    <code>href="http://website/public/assets/css/reset.css?1345553804"</code>;
    So again, I've changed the asset config, tried:
    <code>'paths' => array('public/assets/') </code>
    and
    <code>'paths' => array(DOCROOT.'public/assets/') </code>
    But it throws <code>Fuel\Core\FuelException [ Error ]: Could not find asset: reset.css</code>
    how could I fix my url links and assets links?
  • That happens because, as you can read in the documentation, the "public" path should be your root folder because you can't put the fuel folder in your root. If you can't access your up folder, you have 2 choises: 1) You can use mod_rewrite and try to delete public from path. It is praticable solution only if you know how to create a perfect .htaccess file. It's not my case, so I uses the solutions 2 2) I modev all the contents of the "public" folder on the root, so I have now this structure:
    - application (the folder where Fuel is- should be Fuel in yours)
    - assets
    - index.php
    . htaccess In your index.php file you have to modify the folders like these (I have "__DIR__.'/application/" you have to put there your fuel's main folder):
    define('APPPATH', realpath(__DIR__.'/application/app/').DIRECTORY_SEPARATOR);
    define('PKGPATH', realpath(__DIR__.'/application/packages/').DIRECTORY_SEPARATOR);
    define('COREPATH', realpath(__DIR__.'/application/core/').DIRECTORY_SEPARATOR);
    

    Now it's time to modify your .htaccess:
    <IfModule mod_rewrite.c>
        RewriteEngine on
        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    

    That's all! Put your base_url to null and all should now works.

Howdy, Stranger!

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

In this Discussion