Server & Hosting

.htaccess Generator

Tick what your site needs — HTTPS, www or not, redirects for moved pages, caching, compression and security headers — and get a ready .htaccess file for cPanel, hPanel and other Apache or LiteSpeed hosting.

Your site

.htaccess

What is .htaccess?

.htaccess is a plain text file in your website’s folder that tells an Apache or LiteSpeed web server how to behave: where to redirect visitors, which files to protect, how long browsers may keep images, and more. Most shared hosting — cPanel, Hostinger’s hPanel, Namecheap and others — reads it, and changes take effect as soon as you save it.

How to add it to your site

  1. Tick the options you need and add any redirects.
  2. Copy the result. In your hosting File Manager, open the public_html folder, show hidden files, and edit .htaccess (or create it).
  3. Paste and save, then open your site in a private window to check that everything loads. If anything breaks, restore the old file.

What the options do

Good to know

Frequently asked questions

How do I redirect http to https with .htaccess?

Tick “Always use https”. The rule checks whether the connection is secure and, if not, sends a permanent (301) redirect to the same page on https.

Why does my site show “too many redirects” after adding the rule?

Usually because a CDN such as Cloudflare connects over http. Tick “My site is behind Cloudflare or a CDN”, or set Cloudflare’s SSL mode to Full.

Where is the .htaccess file?

In the main folder of your site, usually public_html. It starts with a dot, so turn on “show hidden files” in your File Manager or FTP program.