<p>If I understand correctly, take the content of <code>web</code> and place it in <code>subdir</code> so you have:</p>

<pre><code>html/
├── subdir/
│   └── craft/ (config, vendor, templates, .env etc)
│   └── cpresources
│   └── .htaccess
│   └── index.php
└── the main site
</code></pre>

<p>Then in <code>index.php</code> do :</p>

<p><code>define('CRAFT_BASE_PATH', dirname(__DIR__) . '/subdir/craft');</code></p>

<p>And you should have your craft site accessible at <code>mainsite.com/subdir</code></p>

CC BY-SA 4.0
2019-06-07T08:02:43.140Z
2019-06-07T08:02:43.140Z
Oli
<p>My client wants Craft 3 installed in a subdirectory of the main site. So I placed it in <a href="http://mainsite.com/subdir" rel="nofollow noreferrer">http://mainsite.com/subdir</a>.</p>

<p>The issue now is that the webroot for the domain is at <a href="http://mainsite.com" rel="nofollow noreferrer">http://mainsite.com</a>, so my Craft <code>index.php</code> isn't being hit when I go to <a href="http://mainsite.com/subdir" rel="nofollow noreferrer">http://mainsite.com/subdir</a> since it's further down in the <code>/web</code> folder.</p>

<p>I'm trying to pull my <code>index.php</code> out of <code>/web</code> and into the <code>/subdir</code> directory by setting a custom <code>CRAFT_BASE_PATH</code>, but I've tried several different paths to no avail.</p>

<p>The error is simply: "This page isn’t working. mainsite.com is currently unable to handle this request. HTTP ERROR 500"</p>

<p>My directory structure is: </p>

<pre><code>var/www/html/subdir/
├── craft/
│   └── config, vendor, templates, .env, web etc
├── index.php
</code></pre>

<p>But if it would be better if I stuffed <code>index.php</code> back into <code>/web</code> and went about this a different way I'm all ears. I'm not the network admin, so if there is a way to set a custom root for a subdirectory on the server or something, I'll have to ask someone else to do it for me, which is fine if that's the best way to do it.</p>

<craft3>
CRAFT_BASE_PATH problems when installing Craft 3 in subdirectory
# CRAFT_BASE_PATH problems when installing Craft 3 in subdirectory

(Asked by: username_0 on 2019-06-07)

My client wants Craft 3 installed in a subdirectory of the main site. So I placed it in http://mainsite.com/subdir.
The issue now is that the webroot for the domain is at http://mainsite.com, so my Craft index.php isn't being hit when I go to http://mainsite.com/subdir since it's further down in the /web folder.
I'm trying to pull my index.php out of /web and into the /subdir directory by setting a custom CRAFT_BASE_PATH, but I've tried several different paths to no avail.
The error is simply: "This page isn’t working. mainsite.com is currently unable to handle this request. HTTP ERROR 500"
My directory structure is: 
var/www/html/subdir/
├── craft/
│   └── config, vendor, templates, .env, web etc
├── index.php

But if it would be better if I stuffed index.php back into /web and went about this a different way I'm all ears. I'm not the network admin, so if there is a way to set a custom root for a subdirectory on the server or something, I'll have to ask someone else to do it for me, which is fine if that's the best way to do it.

**Tags:** craft3


---

## 1 answers

### Answer by username_1 on 2019-06-07. Score: 1

If I understand correctly, take the content of web and place it in subdir so you have:
html/
├── subdir/
│   └── craft/ (config, vendor, templates, .env etc)
│   └── cpresources
│   └── .htaccess
│   └── index.php
└── the main site

Then in index.php do :
define('CRAFT_BASE_PATH', dirname(__DIR__) . '/subdir/craft');
And you should have your craft site accessible at mainsite.com/subdir


---

