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 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

如何使用 cPanel 下载备份?(视频)

使用cPanel下载备份是一个简单的过程。以下是帮助您安全下载网站备份的逐步指南: 第一步:登录cPanel 打开您的网页浏览器。...

如何生成Sapna备份并发送到FTP服务器? (视频)

生成cPanel备份并将其发送到FTP服务器是一个简单的过程。以下是具体步骤: 第1步:登录cPanel...

如何在 cPanel 中恢复备份?(视频)

在 cPanel 中恢复备份是一个简单的过程,可以高效地恢复您的网站数据。以下是恢复备份的分步指南: 第一步:登录 cPanel 打开您的网页浏览器,访问...

如何在 cPanel 中更改账户密码?(视频)

在cPanel中更改账户密码非常简单,只需几个步骤即可完成。请按照以下说明操作。 第一步:登录cPanel...

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

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