Using subdomain without multisite setup help

Hello. I am trying to setup my site on a sub domain folder. The site is not a multi site. I can get the site to work if I use the address:

sub.mydomain.com/web/

However, that obviously means that
sub.domain.com shows all the root files (composer.json, web folder, config folder etc). I used these rules in my env file:
WP_ENV=‘development’
WP_HOME=‘https://sub.mydomain.com/web
WP_SITEURL="${WP_HOME}/wp"

That let me get the site working if I view the web folder but not what I want. I want it to run so that you don’t see the root folder and from the front end perspective “web” folder is basically invisible. I hope that makes sense. I tried changing to:
WP_HOME=‘https://sub.mydomain.com/
WP_SITEURL="${WP_HOME}/web/wp"

But that showed the site with missing stylesheets etc. I’m sure there is a htacess rule I could use but I’ve been searching and cannot find how this is possible.

Please help.

You’d configure this outside of bedrock: Bedrock doesn’t know anything about server level routing, which is what you need to do here. Using whatever system you use to associate a domain with a web root, you need to associate a subdomain with the bedrock web root.

1 Like

Thank you. I found this video How to Deploy WordPress with Bedrock to Shared Hosting - YouTube which let me know that if I add the following into the sub domain root folder that it all works nicely.

`#this is for subdirectory

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.mydomain.com.au$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.sub.mydomain.com.au$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]

BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress`

And then in env changed back to WP_HOME=‘https://sub.mydomain.com.au/’. All working now.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.