Domain redirects are essential for maintaining SEO rankings, consolidating traffic, and ensuring a smooth user experience when changing URLs or domains. This guide covers how to set up redirects using cPanel tools and .htaccess rules, including advanced configurations for HTTPS enforcement and canonicalization.


Why Redirects Matter

  • SEO Preservation: Prevents loss of search engine rankings when URLs change.
  • User Experience: Ensures visitors reach the correct page without errors.
  • Brand Consistency: Redirects old domains to new ones seamlessly.

Types of Redirects

  • 301 (Permanent): Best for SEO; signals search engines that the page has moved permanently.
  • 302 (Temporary): Indicates a temporary move; not ideal for SEO.
  • Meta Refresh: Avoid unless necessary; slower and less SEO-friendly.

Step 1: Using cPanel Redirect Tool

  1. Log in to cPanel.
  2. Navigate to Domains → Redirects.
  3. Select:
    • Type: Permanent (301) or Temporary (302).
    • Domain: Choose the domain to redirect.
  4. Enter the destination URL (e.g., https://newdomain.com).
  5. Click Add.

Tip: Use 301 for SEO-critical redirects.


Step 2: Advanced Redirects via .htaccess

For complex rules, edit .htaccess in public_html:

Redirect Entire Domain

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]
``

Force HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 

Redirect Non-WWW to WWW

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
 
 

Step 3: SEO Best Practices

  • Avoid redirect chains (e.g., A → B → C).
  • Update internal links to point directly to the new URL.
  • Submit updated sitemap.xml to Google Search Console.
  • Use canonical tags on new pages to reinforce preferred URLs.

Step 4: Testing Redirects

  • Use curl or online tools like https://www.redirect-checker.org/:
 
curl -I https://olddomain.com
 

Expected output:

HTTP/1.1 301 Moved Permanently
Location: https://newdomain.com/

Troubleshooting

  • Redirect Loop: Check .htaccess for conflicting rules.
  • HTTPS Errors: Ensure SSL is installed before forcing HTTPS.
  • Slow Redirects: Avoid meta refresh; use server-side redirects.

Security Considerations

  • Validate destination URLs to prevent open redirect vulnerabilities.
  • Restrict .htaccess editing permissions to trusted users.
Bu cavab sizə kömək etdi? 31 istifadəçi bunu faydalı hesab edir (121 səs)