Developer

Htaccess Rule Generator

Build .htaccess redirects, rewrites, and basic auth rules.

All tools

Rules

Generated .htaccess

RewriteEngine On

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

# 301 redirect
RewriteRule ^old-page$ /new-page [R=301,L]

Frequently asked questions

What's the difference between Redirect and RewriteRule?
Redirect from mod_alias is a simple URL-prefix mapping that sends a 301 or 302 to the client, while RewriteRule from mod_rewrite supports regex patterns, conditional flags, and internal rewrites that the browser never sees. Use RewriteRule when you need patterns or conditions.
Why is my .htaccess file being ignored?
Apache only honors .htaccess when AllowOverride is set to All (or the relevant directive group) in the main config, and the file must be readable by the Apache user. Many cloud hosts disable .htaccess in favor of central config.
When should I use a 301 redirect versus a 302?
Use 301 for permanent moves so search engines transfer ranking signals and browsers cache the redirect aggressively. Use 302 for temporary moves like A/B tests or maintenance pages where the original URL will return.