Redirects & Error Pages in Apache

From the Apache cheat sheet ยท htaccess & URL Rewriting ยท verified Jul 2026

Redirects & Error Pages

Simple redirects with mod_alias and custom error pages

apacheconf
# Permanent redirect (301)
Redirect 301 /old-page https://example.com/new-page

# Custom error pages
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
๐Ÿ’ก Use Redirect (mod_alias) for simple URL redirects โ€” mod_rewrite is overkill for basic cases
โšก 301 is permanent (cached by browsers, transfers SEO); 302 is temporary (not cached)
๐Ÿ“Œ Force HTTPS with RewriteCond %{HTTPS} off โ€” the most common rewrite rule on the web
๐ŸŸข ErrorDocument paths are relative to DocumentRoot โ€” create an /errors/ directory for custom pages
redirecterror-pageshttps

More Apache tasks

Back to the full Apache cheat sheet