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