Redirects
Learning Focus
By the end of this lesson you will know the different redirect types and how to implement them.
Redirect Types
| Code | Type | When to Use |
|---|---|---|
| 301 | Permanent redirect | URL changed forever (SEO-safe) |
| 302 | Temporary redirect | Temporary move, testing |
| 307 | Temporary (preserve method) | API redirects that must keep POST |
Implementing Redirects
Via .htaccess
# Permanent redirect (single page)
Redirect 301 /old-page https://example.com/new-page
# Pattern-based redirect
RewriteRule ^old-section/(.*)$ /new-section/$1 [R=301,L]
# Redirect entire domain
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
Via WebAdmin Context
- Virtual Hosts → select vhost → Context → Add
- Choose Redirect type
- Set the source URI and destination URL
- Set status code (301 or 302)
- Save and Graceful Restart
Key Takeaways
- Use 301 for permanent, SEO-safe redirects.
- Use 302 for temporary redirects during testing.
- Place redirects in vhost config for better performance over
.htaccess.
What's Next
- Continue to .htaccess Compatibility for Apache compatibility details.