We utilize cpanel for our web hosting, which will point your main domain to public_html by default. This is fine in some cases, but in others you may wish to host your main website out of a subdirectory so that you can host multiple sites/domains/subdomains on your plan. In order to do this, we will need to create an .htaccess file that redirects the traffic for you. In addition, depending on if you are using a CMS for your website (and which CMS that is), there will be additional steps to follow.
- Place the following .htaccess into your root public_html directory:
-
RewriteEngine on
options -indexesRewriteRule ^$ <SUBDIRECTORY>/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ <DOMAINNAME>/$1 [L]
-
-
Add any needed items for your specific CMS in this scenario. As we discover these, we will list them below:
-
Drupal:
-
from an SSH session, run the following: "chmod -R a+w /public_html/<SUBDIRECTORY>/sites/default"
-
Add the following to the bottom of your /public_html/<SUBDIRECTORY>/sites/default/settings.php:
-
if (isset($GLOBALS['request']) and '/<SUBDIRECTORY>/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}
-
-
Common signs you need to do this:
-
After editing mostly anything on your drupal site, your receive the following message: "Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.". In addition to this, you may notice the /path/to/what/you/are/doing is repeated onto itself a second time.
-
-
-
Wordpress:
-
*Unknown if there is anything needed for wordpress, coming soon*
-
-