How to edit .ht(Hypertext) access file through cPanel File manager? (Video)

Editing the .htaccess file through cPanel File Manager allows you to make server-level configurations for your website, such as redirects, access rules, and performance settings. Here's how you can edit it safely.


Step 1: Log in to cPanel

  1. Open your web browser and navigate to your cPanel login page (e.g., https://yourdomain.com:2083).
  2. Enter your username and password, then click Log in.

Step 2: Access File Manager

  1. In the cPanel dashboard, scroll to the Files section.
  2. Click on File Manager.

Step 3: Locate the .htaccess File

  1. In the File Manager interface, navigate to the root directory of your website:
    • For the primary domain, go to the public_html folder.
    • For subdomains or add-on domains, navigate to the respective folder.
  2. If you cannot see the .htaccess file:
    • Click on the Settings button in the top-right corner of File Manager.
    • Check the box for Show Hidden Files (dotfiles).
    • Click Save.

Step 4: Backup the .htaccess File

  1. Before making any edits, create a backup of the existing .htaccess file:
    • Right-click on the file and select Copy.
    • Save the copy in the same directory or another safe location (e.g., name it htaccess-backup).

Step 5: Edit the .htaccess File

  1. Right-click on the .htaccess file and select Edit.
  2. A pop-up may appear asking to confirm encoding. Click Edit to proceed.

Step 6: Make Changes to the File

  1. In the text editor that opens, make the necessary changes to the .htaccess file.
    • Common configurations include:
      • Redirects:  Redirect 301 /old-page.html http://example.com/new-page.html
      • Deny Access by IP:  Deny from 192.168.1.1
      • Enable Compression:  AddOutputFilterByType DEFLATE text/html text/plain text/xml
    •  

Step 7: Save Changes

  1. After editing, click Save Changes in the top-right corner of the editor.
  2. Close the editor.

Step 8: Test Your Website

  1. Open your website in a browser to ensure it is functioning correctly after the changes.
  2. If the website is broken or shows a server error (e.g., 500 Internal Server Error), revert to the backup file:
    • Rename the backup file to .htaccess to restore it.

Tips for Editing the .htaccess File

  • Make Incremental Changes: Edit only one section at a time and test your website after each change.
  • Use Commenting: Add comments to explain your changes for future reference.
    Example:

              # Redirect old page to new page
                 Redirect 301 /old-page.html http://example.com/new-page.html

  • Validate Syntax: Double-check your syntax, as .htaccess is very sensitive to errors.

Editing the .htaccess file through cPanel File Manager is a powerful way to configure your server. By following these steps carefully, you can make changes safely and efficiently.

  • 0 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

How to Download Backup using cPanel? (Video)

Downloading a backup using cPanel is a straightforward process. Here's a step-by-step...

How to generate a cPanel backup and sent it to FTP Server? (Video)

Generating a cPanel backup and sending it to an FTP server is a straightforward...

How to restore a backup in cPanel? (Video)

Restoring a backup in cPanel is straightforward and allows you to recover your website’s data...

How to change an account password in cPanel? (Video)

Changing an account password in cPanel is simple and can be done in a few quick steps. Follow...

How to update your contact information in cPanel? (Video)

Updating your contact information in cPanel is important to ensure you receive critical...