You can choose to forward your old domain to another if you happen to not have a hosting plan. Redirection allows you to redirect the client domain to a different URL. You can use it when you’re switching domains, changing how your site is structured, or switching to HTTPS.
In this article, I’ll show you how to redirect a domain without hosting to another. I’ll explain exactly how forwarding urls work and show you what happens behind the scenes.
Note, you can redirect from an http:// URL on your domain to a separate website with https:// as this type of redirect is simple domain forwarding.
How Does Basic Redirection Work?
You can automatically forward and redirect your website domain to another address. You can choose to forward all, or just certain URLs.
Before we dive into the specifics of redirection, let’s quickly understand how exactly a website redirection works. Redirection is useful when you’ve already built a website elsewhere, or if you want to connect your domain to a social media page..
Let’s say we’ve just moved our website and we want to shut down the old one. However we don’t want all those pages from the old site to give a 404 Not Found. What we need is for those old links to point to the same content on our new site.
Step 1 – Set up on how to redirect a domain without hosting: Cloudflare
We will use cloudflare for our destination. Before you change your domain nameservers to Cloudflare, you will need to first, set up Cloudflare on your domain which you would like to create a redirection from.
If your domain is registered with Godaddy or any hosting provider, all you will need to do is change your nameservers to the new one and wait for it to propagate.
Log in to your GoDaddy Account
- Remove nameserver
- Replace with Clouflare nameservers
Note: DNS changes can take up to 24 hours to fully propagate. If DNS changes were made, please allow up to 24 hours.
Once your domain fully propagates, you can setup redirect in your Cloudflare account.
Step 2 – Set up a redirect
Redirect with a secure connection (HTTPS) is possible only to a different destination domain example http://www.olddomain.com to https://www.newdomain.com. If you need this type of redirect (HTTP >> HTTPS) or vice versa (HTTPS >> HTTP) within one domain name (http://domain.tld to https://domain.tld) , it should be done via the .htaccess file.
Redirecting a domain with the .htacess file
Perhaps the simplest way to redirect to another URL is with the .htaccess
.htaccess` is a document that gives us the ability to give orders to Apache, that bit of software that runs on the server. The .htaccess file is created on its own when you install WordPress for the first time. It’s an extremely important file that allows you to give specific instructions to the hosting server. The file is used for carrying out functions like redirects, modifying website configuration and even securing your WordPress site. The .htaccess file is generally hidden. The reason being it’s a very important file and WordPress wants to protect it from any potential danger such as being accidentally deleted.
To redirect users to our new site we’ll make a new .htaccess file (or edit the existing one) and add it to the root directory of the old website.
- Locate and download your .htaccess file. An .htaccess file is a file that web servers check for information on how to handle errors, security, and redirect requests for your site. Check your root directory (where all your website files are stored) and then download the file for editing.
- Create an .htaccess file. If no .htaccess exists in your root folder currently, you can create one using an application like Notepad (or a similar plain text application).
- Paste the following code into the .htaccess text file: “redirect 301 /old/olddomain.com http://www.newdomain.com
- Set the new URL destination. Change “http://www.newdomain.com” to the domain address you’d like visitors to be redirected to
To route web traffic through the domain networks, update the nameservers at your domain registrar to resolve your domain’s DNS (Domain Name System) nameservers.