FB pixel

Configuring Redirects for Domain Forwarding

22 18.07.2025

What is a Redirect?

A redirect is a mechanism that automatically sends a visitor from one URL to another. When a web server receives a request for a specific resource, instead of delivering it, it informs the browser to navigate to a specified new address. This is particularly important when changing a website's structure, or domain name, or preserving SEO traffic during a migration to a new resource.

When is Domain Forwarding Necessary?

Domain forwarding may be needed in various scenarios:

  1. Switching to a new domain: If you are changing your website's name, it is essential to set up a redirect from the old domain to the new one so that visitors and search engines are automatically directed to the correct address.
  2. Traffic consolidation: If you have multiple domains pointing to the same resource, you can configure a redirect to the primary domain for better user experience and SEO optimization.
  3. Avoiding duplicate content: If your site is accessible with both the "www" prefix and without it, it is advisable to set up a redirect to choose one canonical version and prevent page duplication.
  4. Changing site structure or pages: If you update the URLs of individual pages, a redirect helps retain their search engine rankings and ensures a seamless transition for users to the new address.

How to Set Up Domain Forwarding

There are several methods to configure redirects. The choice depends on your resources and available tools:

  • Using web server configuration files (Apache, Nginx);
  • Modifying the .htaccess file (relevant for hosting based on Apache);
  • Configuring redirects via the hosting control panel;
  • Using built-in CMS features or plugins (e.g., for WordPress).

Below are some common methods explained in detail.

Redirect via Web Server Configuration (Apache/Nginx)

Apache

In the virtual host configuration file (/etc/apache2/sites-available/example.conf), add the following rule:


ServerName old-domain.com
Redirect 301 / http://new-domain.com/

This code will redirect all requests from old-domain.com to new-domain.com using a 301 status code, indicating a permanent move.

Nginx

In the site configuration file (e.g., /etc/nginx/sites-available/example), add the following:

server {
listen 80;
server_name old-domain.com;
return 301 http://new-domain.com$request_uri;
}

This setup redirects all requests from old-domain.com to new-domain.com, preserving the path and query parameters.

Restart the server after making changes:

  • For Apache: sudo service apache2 restart
  • For Nginx: sudo service nginx restart

Redirect via .htaccess File

The .htaccess file is a configuration file for Apache that allows you to define redirect rules without accessing the primary configuration files. This is especially convenient for shared hosting.

Example of domain forwarding using .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]

This code checks if the requested domain is old-domain.com and redirects it to new-domain.com. The 301 status code informs search engines that the move is permanent.

Redirect via Hosting Control Panel

Many hosting providers offer user-friendly interfaces for setting up redirects:

  1. Log in to your control panel (e.g., cPanel, Plesk, or similar).
  2. Locate the "Redirects" or "Forwarding" section.
  3. Specify the old domain and the new address for the redirect.
  4. Save the changes.

This method is particularly easy as it eliminates the need for manual editing of configuration files. Once the changes are saved, the control panel automatically writes the necessary rules for you.

Conclusion

Setting up redirects for domain forwarding is a crucial step to maintaining website rankings in search engines and ensuring a smooth user experience during changes to site structure or domain name. You can use web server configuration files, the .htaccess file, or a hosting control panel. The choice of method depends on your server access and personal preferences. A properly configured redirect guarantees uninterrupted and reliable website operation in the long term.

Learn more about how to purchase a domain, hosting, VPS, or dedicated server.

FAQ

What is a 301 redirect used for?

A 301 redirect is used for permanently redirecting users and search engine crawlers from one URL to another. This is necessary when a page has been moved to a new address, and you want to retain its authority and ranking. A 301 redirect signals to search engines that the old URL is no longer valid and transfers all its value to the new URL.

Can I use DNS for URL forwarding?

Yes, DNS can be used for URL forwarding. This is known as a DNS redirect, and it allows you to forward all traffic from one domain to another. However, DNS redirects are generally used for redirecting entire domains rather than individual pages. For more precise redirects at the page level, 301 redirects are typically used.

What is the difference between a 301 and a 302 redirect?

A 301 redirect indicates a permanent move, meaning the page has been relocated permanently to a new URL. A 302 redirect denotes a temporary move, implying the page may return to the original URL in the future. A 301 redirect transfers the full authority and ranking of the old URL to the new one, whereas a 302 redirect does not transfer the full value as it is considered temporary.