DISQUS

Ninja vs Penguin: CakePHP Install: Multiple Subdirectories & 500 Error

  • jahypee09 · 2 years ago
    Hi. Is the solution for problem 2 complete? I can't seem to find the edited versions of the 3 .htaccess files? Can I have the link if it's posted someplace else? Thanks! =)
  • NinjaVsPenguin · 2 years ago
    Yes, the solution to problem 2 is complete. You shouldn't have to edit the .htaccess files. The only one you might have to edit is the first one:

    First: in the core cakephp directory
    /cake

    contents of .htaccess (unedited)

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

    This tells cakePHP where you webroot is. If you have a basic install, then this shouldn't need to change. If you have a different directory for your apps, then you'll need to change the directories accordingly.

    HTH.

    -Penguin
  • Blackie · 2 years ago
    Thanks for this post. Part 2 should be included into cake manual! :-)
  • Dave · 2 years ago
    Nice article. Very helpful. Can you attach your htaccess per your article? Since you moved your webroot dir you can't be using:

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

    I am a newbie to working with rewrite rules and I can't figure out how to path it properly.
  • joren · 2 years ago
    hey thanks alot for the help to start, i have made some modifications that might help alot of people ..

    these small modifications will save you lots of works!!

    what they do are the following :
    generate on-the-fly the ROOT-location and more!!!

    i have tested it and i loved it myself :)

    ===========================

    so what you need to do is, open the original /app/webroot/index.php
    go to line 41 and replace the following lines with the original!


    chdir("../../");
    $root = getcwd();

    if (!defined('ROOT')) {
    //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
    //You should also use the DS define to seperate your directories
    define('ROOT', $root.DS.'apps');
    }
    if (!defined('APP_DIR')) {
    //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
    define('APP_DIR', basename(dirname(__FILE__)));
    }
    /**
    * This only needs to be changed if the cake installed libs are located
    * outside of the distributed directory structure.
    */
    if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
    //You should also use the DS define to seperate your directories
    define('CAKE_CORE_INCLUDE_PATH', $root);
  • NinjaVsPenguin · 2 years ago
    Thanks, Joren! It looks great!
  • joren · 2 years ago
    addition :
    due to posting the ’ needs to be changed to ' (the single apos next to enter)
  • Alun · 2 years ago
    The locations of the three files are

    root/
    root/app
    root/app/webroot

    not cake as you suggested above ;)

    Thanks for the articel though it's helped me sort my problem out. I had to add RewriteBase / to each .htaccess and it all works great now :)
  • scott · 1 year ago
    I changed my setup to match this configuration and ALMOST everything was working. I couldn't get the bake console script to work. It wouldn't copy files when creating a project or write the models files.

    I moved the app files below the webroot and bake starting working again.

    Any idea why?
  • NinjaVsPenguin · 1 year ago
    Hi Scott,

    I never actually got Bake to work, not even in the "normal" configuration. So, unfortunately, I can't be of any help.

    Good luck with your projects!
    -Penguin
  • rollins · 1 year ago
    Thanks for the tips. I ended up just sticking the entire cake directory into ~/public_html, and named it for my application. Then I took Alun's advice and added RewriteBase /~user/application to each of the .htaccess files. Then I just stuck a redirect from ~user to ~user/applicaiton an I was good to go.
  • NinjaVsPenguin · 1 year ago
    Hi rollins,

    That's some nice .htaccess ninja you got going. I'm glad you were able to find a solution that works for you :)

    -Penguin
  • spamguy · 1 year ago
    Damn, I wish I had found this post two weeks ago. I would have saved so much configuration time. My .htaccess files had all disappeared, so copying and pasting the Apache code from this post still saved the day.

    Awesome job.
  • Caffeine · 1 year ago
    Hey there,

    Just a short note for CakePHP 1.2: If you want to solve the 500 Error with least changes possible just add the appropriate RewriteBase command to the app/webroot/.htaccess file. This is where any request lands somewhere during the "bootstrap process" anyway and it is easy to remove once an application goes live on a single domain.

    Cheers