Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create or edit the .htaccess file in DirectAdmin

The .htaccess file lets you change how your website behaves. This guide shows how to create or edit it in the DirectAdmin File Manager.

DirectAdmin2 min read16 steps6 screenshots

What is .htaccess?

.htaccess is a small text file that sits in a website folder. It gives the web server extra instructions. It works like a note on a door that says "send visitors this way". People use it to redirect pages, force HTTPS, block visitors or set error pages.

The name starts with a dot. Files that start with a dot are hidden on many systems. That is why you may not see it at first.

Warning: One wrong line can break your whole site. Download a copy of the file before you change it.

Steps to edit an existing file

  1. Log in to DirectAdmin.
  2. Click File Manager in the System Info & Files section.
    Screenshot: Click File Manager in the System Info & Files section.
  3. Open the folder domains, then your domain name, then public_html.
  4. Look for .htaccess in the list.
  5. If you do not see it, look for a setting to show hidden files and turn it on.
  6. Click the file name, then choose Edit or View/Edit.
    Screenshot: Click the file name, then choose Edit or View/Edit .
  7. Make your change in the text box.
  8. Click Save.

Steps to create a new file

  1. Open File Manager and go to public_html for your domain.
  2. Click New File or Create File.
    Screenshot: Click New File or Create File .
  3. Type .htaccess as the name. Do not forget the dot at the start.
  4. Click Create, then open the file.
    Screenshot: Click Create , then open the file.
  5. Type your instructions and click Save.

A simple example

This sends all visitors to the secure HTTPS version of your site. Use it only after SSL is installed.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

The first line turns on the rewrite feature. The next two lines say: if the visit is not secure, send it to the secure address.

If the site shows an error after your change

  1. Open the file again.
  2. Remove the lines you added, or paste back your saved copy.
  3. Save and reload your site.

Still stuck? Open a support ticket.

Quick recap

  • .htaccess holds extra rules for your website.
  • It lives in public_html and is hidden by default.
  • Edit it in File Manager and click Save.
    Screenshot: Edit it in File Manager and click Save .
    Screenshot: Edit it in File Manager and click Save .
  • Always keep a copy before editing.