Skip to content
Servers and Linux2 min read

What is the .htaccess file?

Short answer

.htaccess is a plain-text configuration file placed inside a site's folder. The Apache or LiteSpeed web server reads it and applies its rules to that folder and everything below it, such as redirects, forcing HTTPS or blocking access to certain files, without touching the main server configuration.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Common uses with examples
  2. Common mistakes
  3. On ArabyHost

The file name starts with a dot, so Linux and file managers hide it by default. On every request the server looks for .htaccess files in the requested folder and the folders above it and applies what they say. Changes take effect immediately with no server restart, which is exactly why it matters on shared hosting, where customers can’t reach the main server configuration.

Common uses with examples

Force HTTPS across the whole site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

A 301 redirect from an old page to a new one:

Redirect 301 /old-page/ https://example.com/new-page/

Turn off directory listings, protect a sensitive file and set a custom error page:

Options -Indexes

<Files ".env">
  Require all denied
</Files>

ErrorDocument 404 /404.html

Common mistakes

  • A 500 error right after editing: one invalid or unsupported line takes the whole site down. See HTTP 500 explained.
  • Redirect loops: two rules redirect to each other, or HTTPS is forced behind Cloudflare’s Flexible mode, giving ERR_TOO_MANY_REDIRECTS.
  • The file does nothing: Nginx never reads .htaccess; its rules go in the main server configuration.
  • Rules disappearing in WordPress: WordPress writes its permalink rules between # BEGIN WordPress and # END WordPress. Put your own rules outside that block so they aren’t overwritten.
  • Rule order: rules run top to bottom, so place redirects above the WordPress block.

On ArabyHost

ArabyHost runs the LiteSpeed web server, which understands Apache syntax and reads .htaccess files directly, so the usual WordPress and Laravel rules work unchanged. You’ll find the file in public_html in the cPanel File Manager once hidden files are shown. The LiteSpeed Cache plugin adds its own rules to the file too, so leave them in place. Use the htaccess redirect generator to build correct redirects, and the force HTTPS guide once your free SSL certificate is issued.

FAQ

Why can't I see .htaccess in the File Manager?

Its name starts with a dot, so it's treated as hidden. Turn on "show hidden files" in the File Manager settings; if it still isn't there, you can create it in `public_html`.

I got a 500 error after editing it. What now?

Undo your last change or temporarily rename the file to `.htaccess.bak`. If the site comes back, one of the lines you added is the problem, and the error log will say which.

Does .htaccess slow a site down?

A normal file has a negligible effect. Hundreds of duplicated or overlapping rules do slow down every request, so remove what you don't need.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.