Question

After reading over and over again the Installation Instructions for Fuel PHP (which I'm loving), I can't figure out how to make the app work without the url showing public/, and without moving the fuel folder from the docroot. (so it's all sefl-contained).

My setup is this:

/Users/AeroCross/Sites (this is where MAMP is loading all the files, i.e localhost) /Users/AeroCross/Sites/projects/mariocuba (this is the webroot of the Fuel app)

That contains:

    mariocuba/
        .htaccess
        oil
        fuel/
            app/
            core/
            packages/
        public/
            .htaccess

The .htaccess inside the mariocuba folder:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteBase /public

RewriteRule ^(/)?$ index.php/$1 [L]

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

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

The .htaccess inside the public folder:

<IfModule mod_rewrite.c>
RewriteEngine on

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

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

If I try to load the app (/Users/AeroCross/Sites/projects/mariocuba/), this error appears:

Not found.
The requested URL /public/index.php/ was not found on this server.

I don't know what to do in here.

I know that's not designed to work that way, and I know that's insecure, but this is for developing and version control purposes. What can I do (with minimal tweaking of the file system) to make this work?

It's worth noting that I have my config.php file configured with a base_url = null and index_file = null.

Any help appreciated!

Était-ce utile?

La solution

Delete your existing .htaccess file from /mariocuba, move the contents of /mariocuba/public (including .htaccess) into /mariocuba and then edit index.php.

Change:

/**
 * Path to the application directory.
 */
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);

/**
 * Path to the default packages directory.
 */
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);

/**
 * The path to the framework core.
 */
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);

To:

/**
 * Path to the application directory.
 */
define('APPPATH', realpath(__DIR__.'/fuel/app/').DIRECTORY_SEPARATOR);

/**
 * Path to the default packages directory.
 */
define('PKGPATH', realpath(__DIR__.'/fuel/packages/').DIRECTORY_SEPARATOR);

/**
 * The path to the framework core.
 */
define('COREPATH', realpath(__DIR__.'/fuel/core/').DIRECTORY_SEPARATOR);

This is detailed in the install instructions here: http://docs.fuelphp.com/installation/instructions.html#/manual

Autres conseils

Add an .htaccess file in your root directory and use the following rewrite rules:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteBase /YOUR_LOCAL_PROJECT_FOLDER/public

    RewriteRule ^(/)?$ index.php/$1 [L]

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

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

Note: You would need to edit the .htaccess once you upload it to the host (since it cannot be dynamically calculated.

If you want to hide everything below the public folder (what I do a lot) use this as the one in the root:

RewriteEngine on
RewriteRule ^(.*) public/$1 [L]

This makes sure all the resources are redirected to public as well. So every thing that's not public is absolutely secure.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top