Hostwinds Tutorials

Search results for:


Table of Contents


Create And Edit An .htaccess File in cPanel
Create And Edit An .htaccess File in Linux Shell (Command Prompt)

How to Create and Edit .htaccess File in cPanel

Tags: htaccess 

Create And Edit An .htaccess File in cPanel
Create And Edit An .htaccess File in Linux Shell (Command Prompt)

Since you're reading this article, you may need to create or edit a .htaccess file. However, you may also be wondering what a .htaccess file is. A .htaccess file is a configuration file specifically to be used in tandem with the Apache webserver. It can allow you to customize things such as how a file or folder is served up or limiting access to specific files or folders. This article will go over how to create and edit a .htaccess file from cPanel and through the Linux shell (command prompt). Let's get started!

Create And Edit An .htaccess File in cPanel

To create a .htaccess file through cPanel, you'll first need to be logged in to cPanel. Once logged in, please refer to the following steps.

Step 1: Click on the File Manager icon located under the files section.

Step 2: Select the location of where you'd like to create this file, such as public_html

Step 3: Click the New File icon.

Step 4: Name the file .htaccess

Step 5: Click Create New File

Note: If you cannot view this file once you have created it, you'll need to enable Show Hidden Files.

Step 6: Locate and right-click the file from the list

Step 7: Select the Edit or Code Edit option from the pop-up menu

Step 8: Click edit

Step 9: You should now be in the editor, which should open in a separate tab

Step 10: Once you're satisfied with any changes you have made, press the Save Changes button

Once the changes have been saved, you may close the editor

Create And Edit An .htaccess File in Linux Shell (Command Prompt)

You must first be logged into the server via SSH. If you're not certain how to access your server via SSH, please refer to the following article, which covers this: Connecting to Your Server via SSH.

  1. Navigate to where you'd like the .htaccess to be created
    1. This can be in various places; however, the syntax is cd /path/to/folder
  2. Use a text editor of your choice to create and edit the file simultaneously
    1. Nano – nano .htaccess
    2. Vi – vi .htaccess
    3. Vim – vim .htaccess

To save the file in Nano press, CTRL+O  then Enter and finally CTRL+X.

In Vim, you'd press the Esc key followed by the colon (:) key and then type wq! in the terminal.

Written by Michael Brower  /  June 22, 2017