From time to time, you may need to move your site. This could be due to a redesign, rebranding, landing page A/B testing for the purpose of marketing, domain change, and traffic redirection towards updated content.

 

How do you make this process seamless? How do you ensure that your user experience is unchanged, or even better? How do you ensure that your site’s performance on search engine results is unaffected? The last thing that you need when moving your site is to have your users constantly plagued by 404 errors.

 

In this article, we explore ways to move your site seamlessly, with a closer look at redirecting using wildcard.

 

server redirect to computer domain, wildcard

 

 

What is a wildcard redirect?

 

Also referred to as a wildcard subdomain or catch-all subdomain, this redirecting option allows browsers to reach your site despite the subdomain users’ requests, even if the directories are not set up. Sometimes, users will mistype subdomains or even request for a random subdomain that is non-existent. A catch-all will help your users access a valid page on your site no matter what they request for.

 

A catch-all allows you to forward subdomains that are yet to be created to a specific page on your new site or even another webpage on the internet. This is usually done via a wildcard DNS record. This record helps in matching user requests for domains that are non-existent. DNS records are usually the leftmost label of a domain name and are preceded by an asterisk and followed by a dot as in *.abc.com

Some exceptions:

 

A DNS record will not cover root domains

 

A root domain is the part that comes after www as in www.abc.com. Root domain lookups don’t return catch-alls. Root records need to be defined for root records without sub-domain specification.

 

Catch-alls do not override already existing records

 

Instead, it picks the random sub-domains and excludes the already defines ones.

 

Other exceptions:

 

  • If you create a separate subdomain, it will take precedence over your wildcard.
  • Catch-all (wildcard) records will only work for A, CNAME, URL redirect, AAA, TXT, and MX record types. They do not work with NS records.

 

301 redirect

 

What about a 301 redirect?

 

At this point, you may be wondering, how about a 301 redirect? Shouldn’t I just use this instead? Well, a 301 redirect is best used in cases where the website address has permanently moved, for instance to a new domain. It will also come in handy if different URLs can be used to access the same webpage. In such cases, one domain is selected and the rest redirect to it. If you are looking to merge 2 sites, a 301 is a good idea too.

 

A 301 does not, however, take into consideration things like mistyped or random domains.

 

This means that for an efficient domain name transfer, you may need to use both a 301 and catch-all.

 

How about .htaccess?

 

Search engines usually take time to discover a 301. This is why Google advises that you test your move using a single subdomain or directory before moving the entire site.

 

Including a 301 in the .htaccess file will “alert” search engines to let them know that there is a new link in place of the old one. Here are scenarios where .htaccess would be viable:

 

  • To “force” either a www or non-www domain version to be used
  • To redirect individual files on the same domain
  • To redirect files with a specific extension
  • To redirect a new domain to a new one

 

Wildcard SSL Certificates

 

We have seen that wildcard redirects take care of subdomains that are non-existent so that users can access a valid page in spite of their requests. What this means that wildcard redirects need to be secure in order not to compromise the integrity and security of your site. This is why wildcard SSL certificates are necessary.

 

What is a wildcard SSL certificate?

 

This certificate, just like a regular SSL certificate, ensures that the connection between your site and the user’s internet browser is secure. The greatest advantage of this certificate is that it allows you to secure primary and unlimited subdomains as well, on a single certificate. This saves you money when compared to having to purchase an SSL for every random sub-domain out there.

 

More benefits of using wildcard SSL certificates

 

Here are some more benefits of using wildcard SSL certificates

 

  • Cost-effective - Since these certificates cater for the most random user requests, they keep being updated to cater for new user requests that had not been captured before. This is usually done at no additional cost. You can also get a trusted site seal which assured your users that your site is safe, again at no additional cost. You can use this seal on pages where customer trust is required, for instance, sign up pages or checkout pages.

 

  • Quick certificate processing - The maximum time it takes to get these SSL certificates is two days. This is because it can be issued after domain validation, which does not take too much time. In this case, it is issued within minutes. If business validation is done, the certificate is issued within two days.

 

  • High compatibility - These certificates tend to be highly compatible, across servers and devices. These SSL certificates have 99% compatibility.

 

 

How to do a wildcard redirect

 

Now that we know what catch-alls are, the DNS records that are used in the redirection process, 301 redirects, .htaccess and the need for SSL certificates, let us now explore various approaches that you can use for wildcard redirects.

 

Using .htaccess for wildcard redirect

 

This method involves manually adding redirects via directly modifying the .htaccess file. This option is great if you are looking to do major redirects, for instance, redirecting a whole domain to another.

 

To access the .htaccess file:

 

Log in to your cPanel

 

Go to Files then File manager

 

 

cpanel to file manager to use .htaccess for wildcard redirect

 

Click Settings

 

Select “Document Root for:”

 

Select your domain name from the dropdown list

 

Select “Show Hidden Files”

 

Click “Save”

 

cpanel .htaccess wildcard redirect

 

Right click on the .htaccess file

 

Select “edit”

 

accessing .htaccess on cpanel

 

If you do not have an existing .htaccess file, you need to create one.

 

To do this, click “New File” on the top-left side

 

Name the file

 

Ensure that the file is named .htaccess (include the dot at the beginning and that the filename is in lower case)

 

Set the directory of the new .htaccess file to /public_html/ or your site’s document root

 

If your text editor pops an encoding dialog box, click “edit”

 

Once you have accessed your .htaccess file or created a new one, here are some 301 redirects that you can use to achieve different goals.

 

Redirecting individual files

 

For example, abc.com/events.htm to abc.com/gallery.htm. Here is the 301 redirect to use:

 

Redirect 301 /events.htm /gallery.htm

 

Redirecting a specific file to another domain

 

For example, abc.com/events.htm to abc.co/gallery.htm, here is the 301 redirect to use:

 

Redirect 301 /events.htm http://abc.co/gallery.htm

 

Redirecting an old domain to a new domain

 

For example from abc.com to abc.co. Note that this will move your entire site. Here is the code to include in the abc.com .htaccess file:

 

RewriteEngine on

RewriteCond %{HTTP_HOST} ^abc.com [NC,OR]

RewriteCond %{HTTP_HOST} ^www.abc.com [NC]

RewriteRule ^(.*)$ http://abc.co/$1 [L, R=301,NC]

 

Forcing the use of a www. version

 

Search engines will see abc.com and www.abc.com as two different sites. Google actually recommends that you choose one and use a 301 redirect to the one that you choose. The code that you will need to force the www version is:

 

RewriteEngine on

RewriteCond %{HTTP_HOST} ^abc.com [NC]

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

 

Forcing the use of a non-www. version

 

This is simply the opposite of the just discussed option. Here is the code:

 

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.abc.com [NC]

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

 

Redirecting all files with a certain extension

 

If you want to redirect all files with a .php extension, for example, abc.com/file.php to abc.com/file.htm, here is the code:

 

RewriteEngine on

RewriteCond %{REQUEST_URI} .php$

RewriteRule ^(.*).php$ /$1.htm [R=301,L]

 

How would you do a wildcard redirect using .htaccess in WordPress?

 

In order to do redirects on your WordPress site, you need to access the .htaccess file. This is how to go about it:

 

Connect to your WordPress site’s root folder. You can do this via File Manager in your cPanel or use FTP.

 

Once you are here, access your .htaccess file.

 

Back up your .htaccess file before making any changes.

 

You can then make the necessary changes (the code is the same as what we had looked at earlier when we discussed .htaccess in the previous section, here we will cover what was not looked at then)

 

Redirecting files to SSL

 

If you have recently added an SSL certificate to your site, you need to add 301 redirects that will send all HTTP traffic to HTTPS. This not only ensures that your visitors access a secure site but also avoids duplicate content.

 

Here is the code:

 

RewriteEngine on

RewriteCond %{HTTP} off

RewriteRule ^(.*)http://%{REQUEST_URI} [L,R=301]

 

Redirecting an entire domain to a new one

 

Here is the code if you are moving the entire WordPress site to an entirely new domain, for example, abc.com to abc.co. Note that this code needs to be added to the old domain name’s .htaccess file (abc.com).

 

#Options +FollowSymLinks

RewriteEngine on

RewriteRule ^(.*)$ http://www.abc.co$1 [,R=301,L]

 

How to use cPanel to perform wildcard redirect

 

This option comes in handy when you want to redirect traffic from one domain to another. Note that you can do this at both domain level and even at webpage level as in redirecting abc.com to abc.co and abc.com/about.html to abc.com/about-us/html. When you create a redirect in cPanel, a redirect rule is automatically added to the .htaccess file.

 

Redirecting an entire domain to a new one

 

Here is how to go about it:

 

Login to cPanel

 

Go to the “Domains” section

 

Click on the redirects button. This should open the Add Redirect page

 

cpanel to file manager using the rediect option for wildard redirect

 

Click the “Type” dropdown

 

Choose a permanent or temporary redirect

 

Click the next dropdown menu

 

Select the domain you want to redirect

 

You can add necessary folder names under the slash (/) field

 

Go to the “redirects to” section and enter the address to which you want to redirect to

 

Select the preferred redirect option (“only redirect with www”, “do not redirect www.”, and “redirect with or without www”

 

To create a wildcard redirect, check the box

 

checkbox wildcard redirect in cpanel instruction

 

The catch-all adds the file/folder name after the redirected URL, for example, abc.com/test.php redirects to ab.com/test.php

 

Click add when you are done.

 

You should see the details of your redirect

 

In conclusion

 

Moving your website or domain is no easy task. It needs to be done carefully and strategically, in order not to lose traffic or affect your ranking on Google. While a 301 direct coupled with .htaccess would work just fine, it is a great idea to use wildcard redirects in order to take care of undefined subdomains that users may request. Catch-alls can also be used even if you are not changing domains, rebranding or anything that may require a redirect, in order to ensure that your users access the correct and valid web pages. Most importantly, wildcard SSL certificates will keep your site secure, especially after doing a wildcard subdomain redirect.