<p>The solution I finally worked out is that the index.php file in the web folder needs to be edited in the following way.
The default code is:</p>
<pre><code>require dirname(__DIR__) . '/bootstrap.php';
</code></pre>
<p>You need to change this to:</p>
<p><code>require dirname(__DIR__,1) . '/***/bootstrap.php';</code></p>
<p>The *** should be replaced by the name of the folder that the bootstrap file is in. The ,1 is how many levels to up in the folder structure from where the index.php is located. In my case the 2 folders are in the same parent folder, so it just need to go up 1 level top find the *** folder.</p>

CC BY-SA 4.0
2022-09-29T10:55:07.257Z
2022-09-29T10:55:07.257Z
Paul Frost
<p>I am using cPanel on a live server and want to install a new craft4 project in a subdomain for testing instead of having a local dev setup on my computer.
I have done this many times for craft 2 and 3.
I usually create a folder on the server named &quot;test&quot; for example, and in that folder I would have 2 folders named public_html and craft. I would move all the contents of the web folder into public_html and the rest into the craft folder.
The subdomain root would point to /test/public_html.</p>
<p>My other Craft3 sites, in the index.php in the web (or public_html) folder had a section for defining path constants. This is what I have in that file:</p>
<pre><code>define('CRAFT_BASE_PATH', dirname(__DIR__,1).'/craft');
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH . '/vendor');
</code></pre>
<p>The knowledgebase on the Craft site has a page, &quot;<a href="https://craftcms.com/knowledge-base/moving-craft-files" rel="nofollow noreferrer">Moving Craft’s Files Below the Webroot</a>&quot;. This tells you to find the line &quot;define('CRAFT_BASE_PATH', dirname(<strong>DIR</strong>));&quot; and to change it. But there is no such line in the Craft 4 /web/index.php file. I know I'm not moving the app folder below root, more like above it,</p>
<p>What should my index.php file look like?
Are there any other files that need editing?</p>

<installation><subdomain>
How to install Craft 4 on a subdomain
# How to install Craft 4 on a subdomain

(Asked by: username_0 on 2022-09-28)

I am using cPanel on a live server and want to install a new craft4 project in a subdomain for testing instead of having a local dev setup on my computer.
I have done this many times for craft 2 and 3.
I usually create a folder on the server named "test" for example, and in that folder I would have 2 folders named public_html and craft. I would move all the contents of the web folder into public_html and the rest into the craft folder.
The subdomain root would point to /test/public_html.
My other Craft3 sites, in the index.php in the web (or public_html) folder had a section for defining path constants. This is what I have in that file:
define('CRAFT_BASE_PATH', dirname(__DIR__,1).'/craft');
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH . '/vendor');

The knowledgebase on the Craft site has a page, "Moving Craft’s Files Below the Webroot". This tells you to find the line "define('CRAFT_BASE_PATH', dirname(DIR));" and to change it. But there is no such line in the Craft 4 /web/index.php file. I know I'm not moving the app folder below root, more like above it,
What should my index.php file look like?
Are there any other files that need editing?

**Tags:** installation, subdomain

---

## 1 answers

### Answer by username_0 on 2022-09-29. Score: 0 | Accepted answer

The solution I finally worked out is that the index.php file in the web folder needs to be edited in the following way.
The default code is:
require dirname(__DIR__) . '/bootstrap.php';

You need to change this to:
require dirname(__DIR__,1) . '/***/bootstrap.php';
The *** should be replaced by the name of the folder that the bootstrap file is in. The ,1 is how many levels to up in the folder structure from where the index.php is located. In my case the 2 folders are in the same parent folder, so it just need to go up 1 level top find the *** folder.


---

