D

Back to Posts

There are several reasons as to why you may wish to look into domain forwarding. No matter what your intentions, carrying out a domain forward is not as difficult as you may think. It can be accomplished in several different ways too, and we are going to discuss each of those methods.

Using Your Registrar

Perhaps the easiest method of forwarding your domain is to do it at your registrar. The bulk of them will allow you to do it for free, and once you have logged into your account, it is going to take no more than a few minutes.

The process for nearly all the major domain name registrars will be the same. It is simply a case of clicking manage your domain, much in the same way as changing your name servers and sorting it out like that.

The only real issue you will have with a registrar will be Network Solutions who charge you for forwarding your domain. So, it may be better if you pay the fee to transfer your domain name away from Network Solutions instead.

Setting Up Forwarding on Your Web Server

You have a couple of options if you want to go down this route.

NGINX

If you are using Nginx for your web server, then browse to this folder:

/etc/nginx/sites/sites-available

Edit your configuration file in the same way you would if you had an Apache server. The following code will go in there:

server {

server_name www.yourdomain.com;

rewrite ^(.*) http://yourdomain.com$1 permanent;

}

Apache

If your server uses Apache, and many do, then you will want to navigate to this folder:

/etc/apache2/sites-available

In there will be a configuration file. Enter the following into there (do not delete any data in the configuration file)

<VirtualHost *:80>

ServerName www.yourdomain.com

Redirect / http://yourdomain.com

</VirtualHost>

It will redirect the www version of your domain name to the non-www version, which is important for SEO. Of course, replace the domain name above with your actual domain name, or it won’t work.

NOTE! You must reload the Apache server with the command → “/etc/init.d/apache2 reload”.

In HTML

If your site is already up and running, you can edit the header of your index.html title. Put the following between the <head> and </head> parts:

<meta http-equiv=”refresh” content=”0; url=http://yourdomain.com/” />

Using .htaccess

A method which is probably going to be a little bit easier for most people will be to edit the .htaccess file, or adding one if it does not exist. You will need to add (or edit) this file in the main directory for your domain name.

This code is what needs to be put in.

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !yourdomain.com$ [NC]

RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

After you set all, just save the .htaccess file.

Conclusion

As you can see, there are several methods you can use for domain name forwarding. There is no one correct method here and it is important that you choose the method that will work best for you.

Share This