How to Install CakePHP 3 in subdirectory

2.7k views Asked by At

How do I install CakePHP 3 in a subdirectory? So far, I've only found that I should set my App.base variable in config/app.php file, but I've tried every path I can think of, but only get 500 error.

Overview of how it should end up:

User goes to www.example.com and gets my 'app1' CakePHP 3 application. User goes to www.example.com/app2 and gets my 'app2' application (standard PHP for now, but eventually another Cake app).

Here's my general file structure:

/
.htaccess *see contents below
application1/
    bin/
    config/
    logs/
    plugins/
    src/
    ...etc
application2/
    index.php - just does an: echo 'APP2!';

I've tried changing my App.base to each of these:

'App' => [
    'base' => '/application1',
    //'base' => '/example.com/application1', 
    //'base' => '/vhosts/example.com/application1', 
    //'base' => '/www/vhosts/example.com/application1', 
    //'base' => '/var/www/vhosts/example.com/application1', 

My .htacess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^application2/?$ /application2/$1 [R=301,L]
</IfModule>

What am I missing? Are there other steps I need to take? Is what I've done so far incorrect?

1

There are 1 answers

0
ConquestXD On

In www.example.com/app2

Modify yur .htaccess to the following:

RewriteEngine On
RewriteBase /application2/
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]