Bedrock/web as root directory on a shared server

What is the best or cleanest way to point a domain to the /bedrock/web root directory on a shared hosting server?

I’ve read that a rewrite in the .htaccess file would be a security issue since there is other stuff in that directory.

I’m in a bit of a time crunch and I’d hate to have to lose any of the functionality of Bedrock that i’ve spent so much time learning and implementing by simply moving the /web directory to the root!

1 Like

This has been brought up before if you do some searches, but we won’t recommend or support this whatsoever

OK - I came to the same conclusion and moved my site to a VPS server with a dedicated IP.

Even with that, I’m having some trouble with the steps in this new server environment and have a site going live today.

  1. I’ve mostly followed the “Using a pre-existing subdirectory install” instructions from: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

  2. Copied the htaccess file and index.php - and changed my index.php to include:
    require(DIR . ‘bedrock/web/wp/wp-blog-header.php’);

  3. Updated my env file to include:
    WP_HOME=http://www.domain.com/bedrock/web
    WP_SITEURL=${WP_HOME}bedrock/web/wp

Are there any other steps to take? An update maybe in the application.php file?

Thanks in advance for your help - i’m really in a pinch.

So you now have full root access to your hosting right? Do you have write permissions one level above your public_html folder? If so, move your .env file, config & vendor folders one level above your web root.

You shouldn’t have to follow those instructions. have a look a the Bedrock documentation: https://roots.io/bedrock/docs/folder-structure/

No need to do that either, change it back to default:
require(__DIR__ . '/wp/wp-blog-header.php');

Also not necessary, change it back to default:

WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp

Treat your local Bedrock web folder as the remote public_html folder on your VPS.

Change the $webroot_dir path in config/application.php and replace web so it matches your root folder name (public_html, httpdocs etc)

├── .env
├── config
├── vendor
└── public_html
       ├─ .htaccess
       ├─ app
       ├─ wp
       ├─ index.php
       └─ wp-config.php

That should basically be it.

1 Like

Thanks for the quick reply! Will give this a whirl… I was definitely going down the wrong path.

Let me know if it worked out

No, i’m still trying to resolve this…

What kinda errors are you getting?

I’ve moved up Bedrock, and the contents of Web to my public html directory, and made the change for the public access directory name to be replacing /web in application.php file.

I’m still getting a redirect to bedrock/web and a 500 Internal Server Error

Does the db home url need to be updated?

The config and vendor folders shouldn’t be in a bedrock folder, just in the home directory. if you do want that you should update the paths in wp-config.php. That web folder in bedrock shouldn’t be there either. Also not seeing your .env file? Is it in the home directory too?

So i’m really only moving the .env, config and vendor folders up - and leaving everything else in place?

I don’t know with which paths you imported your db?
Should be the same as:

WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp

Jup, and with your app, wp, index.php & wp-config.php in your web root

OK - so I have:

WP_HOME=http://example.com/bedrock/web (which i’m changing now to just example.com)
WP_SITEURL=${WP_HOME}/wp

Should that now match in the database as well, since that was also example.com/bedrock/web?

That should become: http://example.com/wp

You’re saying that is where it’ll go to - not that I should override the variable ${WP_HOME}, correct?

Yes, remove any old references to bedrock/web in your database and leave the rest as it is

So I switched my home and siteurl to example.com/wp in wp_options.

It’s working! You rock! Thanks so much for all your help!