Skip to main content

Redirects

Learning Focus

By the end of this lesson you will know the different redirect types and how to implement them.

Redirect Types

CodeTypeWhen to Use
301Permanent redirectURL changed forever (SEO-safe)
302Temporary redirectTemporary move, testing
307Temporary (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

  1. Virtual Hosts → select vhost → ContextAdd
  2. Choose Redirect type
  3. Set the source URI and destination URL
  4. Set status code (301 or 302)
  5. 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