What Is .htaccess?
An .htaccess file is a configuration file used by Apache web servers to control server behavior on a per-directory basis. It's commonly used for URL redirects, access control, and URL rewriting — without modifying the main server configuration.
Why It Matters
.htaccess is one of the most common ways to set up redirects on traditional web hosting. It’s powerful but requires Apache hosting and technical knowledge. Understanding .htaccess helps when migrating from self-managed redirects to a dedicated service.
Common .htaccess Redirect Rules
Simple domain redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain\.com [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Redirect single page
Redirect 301 /old-page https://example.com/new-page
.htaccess vs Domain Forward
For a detailed comparison, see our .htaccess vs Domain Forward page.
| Feature | .htaccess | Domain Forward |
|---|---|---|
| Requires hosting | Yes (Apache) | No |
| HTTPS support | Requires separate SSL certificate setup | Automatic |
| Configuration | Regex syntax in text files | Dashboard |
| Path forwarding | Yes (RewriteRule) | Yes (built-in) |
| Wildcard redirects | Yes (RewriteCond) | Yes (built-in) |
| Maintenance | You manage server | Managed |
| Performance | Depends on hosting | <5ms latency |
When to Use .htaccess vs Domain Forward
- Use .htaccess when you already have Apache hosting and need complex URL rewriting alongside an active website
- Use Domain Forward when you need simple domain forwarding without maintaining a server, or when your domain isn’t hosted anywhere
Related Terms
Related Features
Frequently
asked questions
It works but requires Apache hosting, server access, and technical knowledge. For domain-only forwarding, a service like Domain Forward is simpler — no server needed.
No. .htaccess is Apache-only. Nginx uses its own configuration file format. See our comparison of Nginx vs .htaccess redirects.
Still Confused? Try It Free.
Set up your first domain forward in under 5 minutes. Free plan includes 5 domains.