Vannkorn

Full Stack Web Developer

Close

Changing Document Root of a WordPress Website

Helpful when you're using Bedrock WordPress boilerplate.

Ads: Register now via this link to receive $300 credit from Vultr

For those who use Bedrock WordPress boilerplate or someone who plans to modify their web root directory, this post will be handy.

Changing Document Root is fairly easy if you’re using Hestia Panel but it’s a nightmare for those who are using Shared Hosting or cPanels, especially when the domain is set to primary domain.

The solution is simple. Just add the following directives in the .htaccess file from your root directory and it works.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !your/custom-dir/
RewriteRule (.*) /your/custom-dir/$1 [L]

Read my previous post similar to this one here.

I hope this helps. Let me know in the comment below if you guys have any thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *