Loading...

Knowledge Base

How to Edit the .htaccess File

Customers who have signed up to Domain.com before April 1, 2024, can edit the .htaccess file via File Transfer Protocol (FTP) and Account Manager. If you have signed up after that date, you can edit the .htaccess file using FTP.

Editing the .htaccess file offers significant benefits, including optimizing website loading speeds and enforcing more robust security measures. Additionally, it provides a powerful way to customize website behavior, such as URL redirections and access control, and enhances the overall user experience.

Methods to Edit your .htaccess File

Editing .htaccess file via FTP

Note: This is only recommended for advanced users. An error could result in your website(s) being disabled. Your computer should have programs for File Transfer Protocol (FTP) like FileZilla and a text editor such as Notepad.
    1. Login to your FTP client using your FTP credentials.
    2. In the remote site area of your FTP client, find the .htaccess file.
    3. Right-click on the .htaccess file and hit View/Edit.
      View/Edit
Note: Before making any changes to your .htaccess file, please ensure to keep a backup.

Editing .htaccess file via Account Manager

    1. Log in to your Account Manager.
    2. From the left sidebar, click Hosting.
      Hosting Section
      Note: If you have multiple hosting packages, click the MANAGE button on the package in which you want the .htaccess file to be modified.
    3. A new tab will open on your browser. Click .htaccess Editor in the left sidebar.
    4. Once you are on the .htaccess editor page, click the dropdown box to select the domain name you will be applying to the default page.
      Domain Dropdown
    5. If you have multiple domains, they will appear in the dropdown list. Select the domain name you want to modify.
      Domain Options
    6. Click on the directory selector box to select the folder where you want to add or edit a .htaccess file.
    7. Click the Select button after choosing the right directory.
      Select Directory
    8. Choose among the different features of the .htaccess Editor to achieve the changes you want to implement in the file. Refer to the section Features of the .htaccess Editor.

Features of the .htaccess Editor

Direct Editor

Advanced users may need to edit their .htaccess files directly. Select the domain from the dropdown and then a directory, and then click on Use Direct Editor.

Note: This is only recommended for advanced users. An error could result in your website(s) being disabled.

Command Editor

There is a list of specific commands available in the .htaccess Editor that you can add to the .htaccess file depending on your need. You can refer to the following information:

1) Hotlink Protection: Prevent unauthorized URLs from loading files within specified directories at your site. You can choose to redirect these requests and specify URLs that allow access to your site files.
2) Password Protection: Password-protected directories with user access lists.
3) Custom Error Pages: Substitute pages that you designate for standard server error message pages. Custom error pages are useful when you want error pages to match the overall design of your site.
4) Block IP Addresses: Block users from specific IP addresses or a range of IP addresses from accessing your site.
5) Default Pages: Change the home page for a directory from the standard default filenames to the file that you specify. You can also set a prioritized list of default pages.
6) MIME Types: Add or override system MIME types.
7) URL Redirect: Redirect requests for a specific file or directory to a new destination. Redirecting prevents existing links at other sites or in bookmarks from generating 404 - File not found errors.
8) Open Directory Browsing: This allows you to control access to the directories of your website. With this tool, you can choose to display the contents of a directory if no default page is specified.
.htaccess editor
Important note: Settings are inherited commands in a .htaccess file that affect both the directory it is in and any subdirectories of that directory. A file in your home directory will affect your whole site. To override inherited settings in a subdirectory, add a .htaccess file to the subdirectory.

Hotlink Protection

Bandwidth theft (also called hotlinking and leeching) is the direct linking to a website's content, typically images or video. People often use an image tag to display an image from someone else's web page on another site, eBay auction listing, blog, or forum message post. When people request hot-linked images and other files from your site, your plan bandwidth is used, giving this practice the name of bandwidth theft.

1) From the .htaccess Editor, click on  Manage Hotlink Protection.
2) The directory you are protecting is shown at the top.
3) Check the Enable hotlink protection box.
4) To permit requests for the files directly from URLs or links in email messages, click the Allow direct requests checkbox.
5) If you want the requests to be redirected, enter the URL to which requests should be redirected.
6) To specify URLs that are allowed to access files from your site, enter each one on its own line in the designated field. The system automatically adds the main URLs for your plan.
7) Enter the extensions to protect from hotlinking, separated by a space. Click Save to save your settings. Optionally, click Reset to return to the previous settings.
Hot Link Protection

Password Protection

Protecting a directory involves two steps: enabling protection and designating the users authorized to access the protected directory. The Password Protection tool allows you to password encrypt certain directories on your website. You can allow individual users access to these encrypted pages by giving them their own username and password.


Note: Password protection applies to the directory level and cannot be used to protect individual files. If you wish to protect only one file, place that file in its own directory.
 

1) From the .htaccess Editor, click on Manage Password Protection.
2) The directory you are password-protecting is shown at the top. 3) Check the Enable Status switch to green or right.
4) Add a name for this realm, a tag name for this directory.
5) Add Users with Passwords and Save.
6) This list applies to the current directory and all child directories.
6) You can refer to the image below for additional guidance.
Password Protection

Password protection setup outside of this tool may not be manageable with the tool. Please remove the old password protection and re-enable using the tool or manage prior passwords using the tool that set them up.>  

Top of page


Custom Error Pages

You can substitute pages that you designate for the standard server error pages that display when the Web server returns unsuccessful response/status codes. Custom error pages are set in a .htaccess. file. They are useful when you want error pages to match the overall design of your site.

1) From the .htaccess Editor, click  Manage Custom Error Pages.
2) The directory you are password-protecting is shown at the top.
3) Select the Error Status Code from the dropdown arrow.
4) Add the path to your custom error page.
5) Click on the Save Custom Error Page.
6) A visitor will see your custom error page that corresponds with the assigned error code.
7) You can refer to the image below for additional guidance.
Custom Error Pages

Top of page


Block IP Addresses

Block users from accessing your site from specific IP addresses or a range of IP addresses.

1) From the .htaccess Editor, click  Manage Block IP Addresses.
2) The directory you are password-protecting is shown at the top.
3) Click the blue Add IP Address/Range icon.
4) Add the addresses you wish to block.
5) You can refer to the image below for additional guidance.
Block IP Addresses


Note: Blocking an IP Address in range would need this kind of format, e.g. 222.22.22.01/30, which means blocking the range of IP Addresses from 222.22.22.01 ... 222.22.22.30. You can use this website under the IPv4 to check the range of the IP Addresses (https://www.calculator.net/ip-subnet-calculator.html)
 

Top of page
 


Default Pages

Change the home page for a directory from the standard default filenames to a file that you specify. You can also set a prioritized list of default pages. If the first filename listed does not exist, the server will look for the next one, and so on. Click the Add New FileName to create your list of default page filenames. Drag them to the desired order.

Default Pages


Note: If you leave the Default Index Settings box empty, the standard default filenames will be used.
 

Top of page


MIME Types

MIME types tell browsers how to handle files. Most MIME types are set globally on our Web servers.

1) Click Add New MIME type.
2) Enter the MIME type.
3) Enter the file Extension.
4) Click on Save MIME Type.

Mime Types

Top of page


URL Redirects

Redirect requests for a specific file or directory to a new destination. If you change your site structure and rename files or directories, redirecting prevents existing links at other sites or in bookmarks from generating 404 - File not found errors. Visitors will be redirected to new or renamed files.

1) Click Add URL Redirect.
2) Follow the example settings that are provided.
3) Click on Save MIME Type.

URL Redirect

Top of page


Open Directory Browsing

Allows you to control access to the directories of your website. With this tool, you can choose to display the contents of the directory if no default page is specified.

1) Click Manage Open Directory Browsing.
2) Check the Enable Directory Browsing box.

Directory Browsing

Top of page


Related Article

How to Create a 301 Redirect
Top of page
 


Loading...