The .htaccess
file is a powerful tool that helps control how visitors interact with your website. It can be used for security, redirects, URL rewriting, and more. In this guide, we’ll cover what the .htaccess
file does, where to find it, how to edit it, and how to troubleshoot errors it may cause.
What is the .htaccess File?
The .htaccess
file is a hidden configuration file used on Linux-based web servers, including InMotion Hosting’s Shared Hosting accounts. It allows you to make quick changes to how your site functions without modifying the main server configuration.
Since .htaccess
directly impacts how your website functions, always back up your .htaccess
file before making changes.
Where is My .htaccess File?
By default, the .htaccess
file is located in your website’s root directory:
/home/yourusername/public_html/.htaccess
Because it’s a hidden file, you’ll need to enable the Show Hidden Files option in cPanel’s File Manager to see it.
How to Locate and Edit .htaccess in cPanel
- Log in to cPanel.
- Click File Manager under the Files section.
- In the top-right corner, click Settings and check the box for Show Hidden Files (dotfiles). Click Save.
- Navigate to the
public_html
directory and locate the .htaccess
file.
- Right-click the file and select Edit.
How to Create a .htaccess File (If Missing)
If you don’t see a .htaccess
file in public_html
:
- In File Manager, click +File in the top-left corner.
- Name the file .htaccess (with the dot at the beginning).
- Set the directory to
/public_html/
or your website’s document root.
- Click Create File, then right-click it and select Edit.
What Can You Do With a .htaccess File?
The .htaccess
file offers a wide range of functions, including:
Many of these settings can be configured automatically through cPanel, but advanced users can edit .htaccess
directly for more customization.
Troubleshooting .htaccess Errors
Since .htaccess
controls many aspects of your website, incorrect configurations can cause errors. If your website isn’t loading correctly, try these steps:
1. Temporarily Disable .htaccess
You can check if the .htaccess
file is causing an issue by renaming it:
- In File Manager, right-click
.htaccess
and select Rename.
- Change the filename to
.htaccess.old
and save.
- Reload your website.
- If the site loads correctly, an error in
.htaccess
was the problem.
- If the issue persists, rename the file back to
.htaccess
and continue troubleshooting.
2. Check for PHP Configuration Issues
If your PHP settings aren’t applying correctly, you may need to make your php.ini
file recursive. See our full guide: How to Make php.ini Recursive.
Go Unlimited with Exceptional Shared Hosting
Upgrade your Shared Hosting today and take your business to the next level! Get unlimited NVMe SSD storage, cPanel, professional email and over $400 in savings.
Free Domain
24/7 Human Support
100% Money-Back Guarantee
Shared Hosting
Final Thoughts
The .htaccess
file is an essential part of website management, allowing you to control redirects, security settings, and more. Always back up your .htaccess
file before making changes, and if you run into issues, try renaming the file to troubleshoot errors.
Need more help? Check out our full .htaccess reference guide for advanced configurations.