There are a number of reasons you might want to redirect your domain name. Whether you have moved your website to a new domain, or have altered the URL structure on your pages; redirectingyour domain name is vital if you want your new website to establish authority on search engines and among users. Below we will examine exactly what domain forwarding is, as well as the different ways it can be achieved. We will also investigate the pros and cons of specific approaches.
What is Domain Forwarding?
Domain forwarding, or redirecting your domain name, is similar to when a web page brings a visitors to another website, but the domain name itself redirects to the new site. This happens instead of using HTML or a script to complete the redirection. When a domain is used to forward visitors to another site the new page’s URL is displayed in the web browser’s URL instead of the original domain name.
Using stealth forwarding is necessary if you would like the original domain name to remain in the URL bar. Stealth forwarding is when you redirect a visitor to a new domain while having another address displayed in the web browser. There are a number of drawbacks to stealth forwarding. Visitors will not be able to see the site’s sub-directory structure, meaning they will not be able to bookmark pages on the site. This occurs as no matter what page a visitor navigates to, the address in the URL bar will not change.
Redirect with PHP
PHP is an acronym for PHP: Hypertext Pre-processor, although previously it stood for Personal Home Pages. PHP is useful because of the ways in which it can simplify tasks such as redirects. Redirecting with PHP allows you to forward users and search engines from one URL to another using the header function. This method is a server-side solution, as opposed to client-side, which results in a more secure redirect from one page to another. PHP is a popular scripting language because of its flexibility, as well as being easy to learn how to use. Let’s examine how to create a redirect with PHP more closely.
PHP utilises the header function to perform a redirect. The header functions allows you to send the raw HTTP location header, which will perform the redirection. Begin by writing your header function, starting with header (). Next you must define the location response-header field between the brackets with a URL or file. This is the location that you want users to be redirected to. If it is a file it must be in a supported format like HTML, Python, CGI, PHP, or compiled CGI programs. Your new header will look something like this: Header (“Location: http://www.redirectlocation.com/”);. After the semicolon at the end of your header you must add either a die() or an exit() function. Otherwise search engines and bots will be able to ignore the header function. This will result in users remaining on the page you wish to redirect them from. At the end of this process your header should appear like this: (“Location: http://www.redirectlocation.com/”); exit;. Lastly, end the function with <?php and ?> tags, resulting in the finished product looking like this (“Location: http://www.redirectlocation.com/”); exit; ?>. PHP provides a useful redirection solution that is easy to implement.
301 Redirect
301 redirects are the most common type of redirects and are usually used for SEO purposes. They pass almost all of the existing link equity of the domain. When a user visits a webpage and receives a 301 message, it will register that site as having permanently moved to a new location, bringing the user to that new location. It may take some time to build up the indexing of the new page as it will depend on how often a search engine bot visits the page. On a page and domain basis, a 301 redirect is usually a good fit for most situations.
HTTPS and .htaccess Redirects
Redirecting from a HTTP address to a HTTPS address is fast becoming vital to maintaining your online audience. Google Chrome and other search engines are flagging websites without SSL certificates as insecure. SSL, meaning Secure Sockets Layer, is a security protocol that establishes encrypted links between browsers and web servers. This ensures that the data shared between browser and server remains encrypted. In order to create an SSL connection, you will need an SSL certification. In order to move your web traffic from a HTTP connection to a HTTPS connection, you will need to edit codes in the htaccess file.
The .htaccess file instructs the server on how to react to scenarios which directly affect the functionality of your site. This includes redirects and rewriting URLs. The easiest way to edit a .htaccess file is to edit the file and upload it to the server using FTP. You can also use the edit mode in the FTP program which will allow you to edit the file remotely. Other ways to edit the file are by using a text editor and SSH, or using the File Manager in cPanel. Editing your .htaccess file to redirect from a HTTP address to a HTTPS address is a practical example of the importance of secure redirection.
www vs Non-www Redirects
A question that frequently arises for website owners is whether to choose www or non-www URLs: www.example.com vs example.com. A non-www domain is referred to as a ‘naked’ domain and frequently has a number of subdomains attached to it. Choosing a canonical domain, or a definitive domain name, is helpful in creating authority with users and search engines alike. From a technical perspective, there are small differences between a www and a non-www URL. For example, search engines view them as different entities, meaning that they would see example.com and www.example.com as two different websites. This is where redirection becomes important. Search engines will penalise you for duplicated content. You will need to redirect from one page to the other in order to reap the rewards of the content you have created, meaning your naked domain should redirect to your canonical domain to avoid penalties. The benefits of redirecting from one to the other is that search engines will recognise one official domain as the owner of the content, and confer authority on it as a result. As well as this, the redirection experience for users is seamless.
Choosing the Best Redirect Option for You
Being able to redirect your domain is a useful skill, and it doesn’t have to be complicated. Redirects are normally employed to maintain the SEO value of a site, and to pass that authority onto the new domain. A 301 redirection is useful because it informs the servers and the search engines that a site has been permanently moved. This informs them that the original content, which has previously established authority, has moved to another URL.
The best redirection option for you will depend on the reason for the relocation. Generally, using URL redirection on a page by page basis is more successful than redirecting an entire domain. Search engine bots will take a while to verify that an entire domain has moved as a result of scammers abusing the 301 redirection process. Regardless of what approach suits your website best, choosing a secure and verified method will ensure that users continue to trust the content your new site has to offer.