Redirects
Directives
Section titled “Directives”| Directive | Syntax |
|---|---|
Redirect | Redirect [status] url-path target-URL |
RedirectMatch | RedirectMatch [status] regex target-URL |
ErrorDocument | ErrorDocument error-code document |
Redirect Status Codes
Section titled “Redirect Status Codes”| Status | Meaning |
|---|---|
301 | Moved Permanently |
302 | Found (default) |
303 | See Other |
410 | Gone |
Examples
Section titled “Examples”Simple Redirect
Section titled “Simple Redirect”Redirect 301 /old-page /new-pageRedirect /temp-page /other-pageRegex Redirect
Section titled “Regex Redirect”RedirectMatch 301 ^/blog/(.*)$ /articles/$1RedirectMatch ^/category/(.+)/feed/?$ /rss/$1Error Documents
Section titled “Error Documents”ErrorDocument 404 /custom-404.htmlErrorDocument 403 "Access Denied"ErrorDocument 500 https://example.com/error