पाठ 21 / 32

रीडायरेक्ट्स और 404 हैंडलिंग

पेज को स्थानांतरित या हटाते समय SEO मूल्य खोने से बचें।

रीडायरेक्ट स्थिति कोड

301 (Permanent) tells search engines the page moved permanently; links juice transfers to the new URL. 302 (Temporary) means the old page might come back; juice doesn't fully transfer. Always use 301 for permanent moves.

रीडायरेक्ट उदाहरण

Implement redirects at the server level for best performance. Redirect chains (A→B→C) are slower; avoid them.

# Nginx example: Permanent 301 redirect
server {
    listen 80;
    server_name old-domain.com;
    
    # Redirect entire domain
    return 301 https://new-domain.com$request_uri;
}

# Redirect single page
server {
    listen 80;
    server_name example.com;
    
    # Old page moved
    location = /old-article.html {
        return 301 https://example.com/blog/new-article/;
    }
    
    # Remove trailing slash
    location ~ ^(.*)/$
    {
        return 301 $scheme://$server_name$1;
    }
}

404 पेजों को हैंडल करना

Return a true 404 status code for pages that don't exist. Don't redirect to homepage or return 200 OK; crawlers will think the page exists. Create a helpful 404 page with navigation and suggestions.

Canonicalization बनाम रीडायरेक्ट्स

Canonical tags handle duplicate content; redirects handle moved pages. Use canonical for variants of the same content (www vs non-www), redirects for permanent page moves.

रीडायरेक्ट चेन की निगरानी करें

A→B→C chains slow down crawlers. Check your redirects quarterly and fix chains. Test with curl or DevTools to ensure responses are HTTP 301/302, not meta refreshes.