H
10Corp Premium Hosting

Setting Up URL Redirects

Last Updated: 2025-01-01 2 min read

Setting Up URL Redirects

URL redirects send visitors and search engines from one URL to another. They’re essential when you rename pages, move content, change domains, or restructure your website. Proper redirects preserve your SEO ranking and prevent visitors from hitting broken links.

Types of Redirects

TypeHTTP CodeUse Case
Permanent301Page has permanently moved. Transfers ~90% of link equity.
Temporary302Page is temporarily at a different URL. No link equity transfer.
Temporary (strict)307Like 302 but preserves the HTTP method.
Permanent (strict)308Like 301 but preserves the HTTP method.

Use 301 for most cases — it tells search engines to update their index with the new URL.

Apache (.htaccess)

Add redirect rules to the .htaccess file in your web root:

# Single page redirect
Redirect 301 /old-page https://www.yoursite.com/new-page

# Redirect using RewriteRule
RewriteEngine On
RewriteRule ^old-page/?$ /new-page [R=301,L]

# Redirect entire domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldsite\.com [NC]
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]

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

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

Nginx

Add redirect rules in your Nginx server block:

# Single page redirect
location = /old-page {
    return 301 https://www.yoursite.com/new-page;
}

# Redirect entire domain
server {
    server_name oldsite.com;
    return 301 https://www.newsite.com$request_uri;
}

WordPress

Using a Plugin (Redirection):

  1. Install and activate the Redirection plugin.
  2. Go to Tools → Redirection.
  3. Enter the source URL and target URL.
  4. Choose the redirect type (301 or 302).
  5. Click Add Redirect.

Using functions.php:

function custom_redirects() {
    if (is_page('old-page')) {
        wp_redirect(home_url('/new-page/'), 301);
        exit;
    }
}
add_action('template_redirect', 'custom_redirects');

Redirect Chains and Loops

  • Redirect chain: A → B → C. Each hop adds latency and loses some SEO value. Always redirect directly to the final destination.
  • Redirect loop: A → B → A. This causes an infinite loop and an error. Test your redirects carefully.

Best Practices

  • Use 301 for permanent changes — it’s the most common and SEO-friendly redirect.
  • Redirect to the most specific page: Don’t send all old pages to the homepage.
  • Keep redirects minimal: Too many redirects slow down the site and complicate maintenance.
  • Audit regularly: Use tools like Screaming Frog or Google Search Console to find broken redirects.
  • Document your redirects: Maintain a spreadsheet mapping old URLs to new ones.
  • Test after implementation: Visit the old URL and verify it correctly reaches the new destination with the proper status code.
Tags: website redirects 301 302 htaccess seo

Still need help?

Our support team is available 24/7 to assist you.