PricingDocsBlog
Log inSign up
Docs
›
Development

.htaccess overview

Published2023-07-19

Updated2026-10-23

Configure the Apache web server on fortrabbit with `.htaccess`, for redirects, access control, compression and HTTP headers.

Apache web server configuration via .htaccess.
Intro
What to do with .htaccess
Route traffic with smart redirects.
Redirects
Primary domain, moved pages, 301 or 302
Secure areas with authentication.
HTTP auth
Creating a password protected area
Compress responses for faster delivery.
GZIP
Turn on GZIP and Brotli compression
Target rules by environment context.
Environment detection
Rules for production or staging only
Enforce secure connections always.
HSTS
Make browsers use HTTPS only
🗜️
Precompression
Compress CSS, JS and SVG once in the build
Keep abusive 'visitors' out.
Block IPs
Deny single IPs and ranges
Debug .htaccess config problems.
Troubleshooting
Common .htaccess issues and how to detect them
Control HTTP response headers with .htaccess.
HTTP headers
Cache control, CORS, security headers
More .htaccess tricks.
Tips
WordPress, file types, error pages
Build the web you want to see

fortrabbit

PHP hosting for developers.

Running on AWS. Serving worldwide.

Private by design. No cookies.

Since 2012.

Start your free trial →

No spam. No credit card required.

Software

  • Craft CMS
  • Kirby
  • Statamic
  • Laravel
  • ↓ Show all

Solutions

  • You
  • Freelancer
  • Agency
  • Startup
  • ↓ Show all

Workflows

  • Code crafting
  • Agentic dev
  • Vibe coding
  • ↓ Show all

Use cases

  • CMS site
  • Web app
  • Portfolio
  • Weekend hack
  • ↓ Show all

Alternatives

  • Heroku
  • Laravel Forge
  • Laravel Cloud
  • Cloudways
  • ↓ Show all

Company

  • Culture
  • Team
  • History
  • Environment 🍃
  • ↓ Show all

Legal

  • Trust center
  • Terms of service
  • Site notice
  • Data collection
  • ↓ Show all

Contact us

  • Technical help
  • Account recovery
  • Website down
  • ↓ Show all
  • ●New platformLoading
  • ●Old platformLoading