What do these words mean?
The document root is the main folder where your website files live. When someone visits your domain, the server looks in this folder first. On many hosting accounts it is called public_html.
A .htaccess file is a small settings file for the Apache web server. It sits in a folder and changes how that folder behaves. The name starts with a dot, which hides the file on many systems.
You cannot truly change the document root from .htaccess. But you can send visitors to a subfolder, which gives the same result for most people.
Example
Your site files are in public_html/mysite. You want visitors to see them when they open example.com.
Steps
- Log in to your hosting control panel.
- Open File Manager.
- Click Settings and tick Show Hidden Files (dotfiles). Save.
- Go to
public_html. - Find
.htaccess. If it does not exist, click + File and create it. - Right-click it and pick Download to keep a backup.
- Right-click it again and choose Edit.
- Add these lines, changing
example.comandmysiteto your own names.RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteCond %{REQUEST_URI} !^/mysite/ RewriteRule ^(.*)$ /mysite/$1 [L] - Click Save Changes.
- Open your domain in a browser. You should see the site from the subfolder.
What the code does: the first line turns on rewriting. The next two lines check the domain name and make sure the request is not already in the subfolder. The last line quietly serves files from /mysite/.
If it does not work
- Check for typing mistakes in the folder name.
- Restore your backup copy.
- Ask Hostvento support whether your plan allows .htaccess rules. Some setups need a different method.
Quick recap
- The document root is the folder a domain shows.
- .htaccess can redirect requests into a subfolder.
- Back up the file first.
- Add the rewrite rules and save.
- Test your domain.