I need to install Craft under a laravel sub-directory http://example.com/corp/ where example.com is a laravel site.

Does anyone have a clean way to install craft in a directory below an existing app?

Here is my config from /corp/public/index.php

// Path to your craft/ folder
$craftPath = '../../../craftsite/craft';

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';
  • 1
    But do you really want to do this? You are asking for security trouble if you cannot assure very careful maintainenance over time of an .htaccess which refuses any web access to the craft directory. Hard to do. This is why the general advice is to put any app somewhere above web root, so that it never can be accessed. Maybe you need to talk to your corp IT guys to choose such a place? Jul 29, 2014 at 6:40

1 Answer 1


With $craftPath you set the path to the craft/ directory (containing the app/ folder etc.) whereby your index.php is the starting point if you set this as a relative path:

// Path to your craft/ folder
$craftPath = '../relative/path/to/craft_dir/';

As narration_sd pointed out, the craft/ directory should be above the web root for security reasons. But this doesn't mean that you cannot have your index.php at http://example.com/corp/index.php. Just configure $craftPath accordingly. For example:

Laravel at web root:

Craft in a subdir:

Craft app above web root:

Craft's path config:
$craftPath = '../../../craftsite/craft';

Remember to also update the paths to your assets in the Control Panel and the paths to your files linked to in your templates.

  • I guess I should have been more specific. My craft app is located at /var/www/craftsite/craft/app which is not publicly accessible. I then have craft public folder located at /var/www/laravel-site/public/corp Inside this folder is where I have my craft front controller where I set $craftPath = '../../../craftsite/craft'; I can pull up my craft homepage just fine. I can even work in my CP now. What craft cannot seem to do is find my template files. Thanks for the assist. Jul 29, 2014 at 12:58
  • @David edited the answer for you :)
    – carlcs
    Jul 29, 2014 at 13:04
  • Update > Oddly only a single section of my craft site was affected. I changed the Entry URL Format to just {slug} instead of section_name/{slug} and kept my Entry Template as section_name/_entry and everything seems to work. I just lose my section name so my urls look like example.com/corp/about instead of example.com/corp/section_name/about. I would still like to understand what is happening. Jul 29, 2014 at 13:20
  • Not sure if I still follow you (are you talking about a single "single section" that causes/caused problems?). But an idea I have is, that you now get your template by "URI to Template Path matching", read more about routing here (Pt.4 and Pt.6) in the docs.
    – carlcs
    Jul 29, 2014 at 13:38
  • Looks like that is just what I needed. Thanks. Jul 30, 2014 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.