1

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!

AeroCross
  • 3,969
  • 3
  • 23
  • 30

3 Answers3

2

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

James Arnold
  • 990
  • 1
  • 6
  • 15
  • You are so going to heaven, good sir. I salute you from afar. Worked perfectly! – AeroCross Aug 15 '12 at 16:18
  • This does work, but it's in a level deeper for a reason, it's more secure there. So restricting it in such a way that everything in send to the a level deeper would mimic that and make it less difficult to update the framework when needed. – Frank de Jonge Aug 28 '12 at 21:59
1

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.

AeroCross
  • 3,969
  • 3
  • 23
  • 30
heypaxton
  • 11
  • 1
  • This is working pretty nicely (almost perfectly), but the URL's (by the Assets and Html classes) aren't being generated correctly. They all have `public/` prepended — any thoughts on that? – AeroCross Aug 17 '12 at 20:14
  • Did you set your base_url in the main config? – Frank de Jonge Aug 28 '12 at 21:56
0

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.

Frank de Jonge
  • 1,607
  • 1
  • 15
  • 23
  • If I add this to my root (`mariocuba/`), going into `localhost/projects/mariocuba` (the root) sends out a 404. `localhost/projects/mariocuba/public` works, tho. It works as you expect, but what I need is that the public folder can be accesses without refering to it in the URL, and having the fuel folder at the same level of the public folder. – AeroCross Aug 15 '12 at 14:58