What is Primary Domain?
The primary domain is the first domain you purchased at the time of getting the server. In simpler terms, whenever you buy a hosting server, the domain you buy along with the server is known as the primary domain. All the key settings & control for the server will be listed under this domain. These settings will also be applicable to all the other domains which this server will host.What is a .htaccess file?
Htaccess file is a configuration file in a hosting server that has settings or controls on how a user will be able to access the website. Htaccess file is present at the highest level directory of a server and has information about access control, redirection or shortening of URLs etc.Steps to Find the .htaccess file in the File Manager
The first thing is to access the .htaccess file located in your public_html folder. Since this file isn’t visible as a default setting, kindly follow the steps mentioned here to locate & open the .htaccess file:- User must login to their Bluehost.in cPanel account.
- Go to the “Files” section and Click the “File Manager” icon.
- Under the “View Hidden Files” checkbox, kindly select to view the files.
- You are working with your primary domain, so select the WebRoot (public_html/www) option.
- Once .htaccess file is found, right click on it & open with Code Editor option.
Steps to Edit the Subfolder htaccess to host Primary Domain
The code mentioned below will have to be used in the .htaccess file in the public_html folder of the web server account. Modifications or updates in the code (highlighted by #) will need to be done after inserting the code in the file. # Bluehost.in # .htaccess main domain to subdirectory redirect # Do not change this line. RewriteEngine on # Change example.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?example.com$ # Change ‘subdirectory’ to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/subdirectory/ # Don’t change the following two lines. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change ‘subdirectory’ to be the directory you will use for your main domain. RewriteRule ^(.*)$ /subdirectory/$1 # Change example.com to be your main domain again. # Change ‘subdirectory’ to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(/)?$ subdirectory/index.html [L] NOTE: You will need to update “example.com” to your domain at 2 places in the code, and the 3 places of “subdirectory” to the folder where you want your website. The users who visit the website would not be able to differentiate whether the main domain is using a subdirectory or not. The users will view the http://www.example.com/page.html as the website URL address. One thing to iterate here is that these steps won’t work with some website software. In that case, a user will also have to edit & update the $base_url, $live_site or other configuration settings to complete the steps.Steps for Joomla, Drupal and WordPress Users
For users who are on Joomla, Drupal or WordPress, these steps are not endorsed. It is infact better to use the official documentation & use those steps for hosting the primary domain from a subfolder htaccess. The detailed links based on the CMS being used are:- Drupal installed in subdirectory but made to appear in root
- Joomla – Moving the site among directories/sub-directories
- Giving WordPress Its Own Directory
Write A Comment