Wildcard redirects allow you to redirect all URLs to a certain folder on your website. However, there are times when relocating your website is unavoidable. For example, this might result from redesigning, rebranding, or traffic redirection to new content.

But how do you make this process go as smoothly as possible? How can you ensure that your website’s performance in search engine results is unaffected? How do you ensure that your users never get 404 errors?

Redirects are one of the easiest and most efficient ways to accomplish this. Redirects tell search engines and visitors which pages are no longer accessible and where they should go instead.

A wildcard redirect is one way to ensure that users end up exactly where you want them – regardless of how they type in your address or whether they leave out any details.

This article will explain how these work and why they are useful in practice.

What is a wildcard redirect?

A wildcard redirect is a type of redirect that allows you to redirect all traffic from one domain to another. This is useful if you want to move all of your traffic from one domain to another or if you want to redirect all traffic from a specific subdomain to another domain.

It is a redirecting option that allows browsers to reach your website regardless of the subdomain they requested (www.yourdomain.com or even anyname.yourdomain.com) without setting up specific directories for those requests in advance. It is also known as a “catch-all subdomain” or “wildcard subdomain.”

Catch-all subdomains also enable browsers to redirect requests for a mistyped, non-existent, or arbitrary subdomain to a valid webpage on your website.

How does a Wildcard Redirect work? examples

A wildcard redirect is a type of URL redirection that allows you to redirect all URLs that match a certain pattern to a single destination URL. This can be useful if you want to redirect multiple old URLs to a new URL or if you want to create vanity URLs for marketing purposes.

1. Blog Migration Example:

Imagine you’re a blogger who has decided to rebrand. Your old blog at blog.example.com has hundreds of posts, and you’re moving to a new domain, mynewblog.com. Manually redirecting each post would be a monumental task. A wildcard redirect simplifies this process:

  • Old URL Pattern: blog.example.com/*
  • New URL: https://www.mynewblog.com/*

This setup ensures that anyone clicking on a link to blog.example.com/post123 will be seamlessly redirected to https://www.mynewblog.com/post123.

2. E-commerce Category Update:

Suppose you run an e-commerce site and decide to reorganize your product categories. Previously, products were listed under www.examplestore.com/products/category. Now, you’ve changed the structure to www.examplestore.com/category. A wildcard redirect can efficiently manage this transition:

  • Old URL Pattern: www.examplestore.com/products/*
  • New URL: https://www.examplestore.com/*

With this, a customer trying to visit www.examplestore.com/products/shoes will be redirected to https://www.examplestore.com/shoes.

3. Protocol Change (HTTP to HTTPS):

If you’re upgrading your website from HTTP to HTTPS for enhanced security, you’ll want to ensure that all old URLs are redirected to their new HTTPS versions. A wildcard redirect can handle this:

  • Old URL Pattern: http://www.example.com/*
  • New URL: https://www.example.com/*

This ensures all traffic to the HTTP version of your site is automatically redirected to the secure HTTPS version.

4. Subdomain Consolidation:

Let’s say a company has multiple subdomains for different departments (sales.example.com, support.example.com) and decides to consolidate them into a single domain for a unified brand presence. Wildcard redirects can manage this transition smoothly:

  • Old URL Pattern: sales.example.com/*
  • New URL: https://www.example.com/sales/*
  • Old URL Pattern: support.example.com/*
  • New URL: https://www.example.com/support/*

5. Handling Common Misspellings in URLs:

Businesses often use wildcard redirects to catch common misspellings or variations of their domain name. For instance:

  • Old URL Pattern: www.exmaple.com/*
  • New URL: https://www.example.com/*

This redirect ensures that visitors who mistype your domain name still reach your website.

In all these scenarios, wildcard redirects offer a powerful, time-saving solution for website administrators. They ensure a smooth user experience by seamlessly guiding visitors to the correct or updated pages, crucial for maintaining site traffic and SEO rankings during transitions.

Benefits and uses of Wildcard Redirect

moving files

Web admins are well known for employing catch-all redirect to redirect massive volumes of files or pages to a new domain.

This can be useful in several scenarios:

  • You’re changing domains and want to ensure that anyone who visits your old domain will be automatically redirected to your new one.
  • You want to consolidate multiple domains into one main website. For example, if you have acquired another company and their domain now points to your website, you can set up a wildcard redirect so that all traffic from that domain is routed through yours.
  • You want to set up a temporary redirect while making changes to your website. This allows you to redirect visitors to a temporary holding page, so they’re not seeing a broken website while you’re working on it.
  • They are also used when restructuring a website when files must be transferred from one folder to another.
  • You want to create a vanity URL. For example, you may want to set up a redirect from www.example.com/go to www.example.com/products so that visitors can more easily find your products page.
  • You want to route traffic from a non-www version of your domain to the www version or vice versa.
  • Changing the structure of your permalinks or slugs. If you do this, you should redirect URLs that use your old permalink or slug structure to your new one.
  • Combining many posts into one. Some SEO gurus advise combining several little pieces into one massive one. If you do this, you should 301 redirect all minor posts to the main one.

What are some of the exceptions?

1. Root Domain Limitation:

One key exception is that wildcard redirects do not inherently apply to the root domain (also known as the apex domain). This means that if you set up a wildcard redirect like *.example.com -> https://www.newexample.com, it will not automatically redirect example.com (the root domain) to https://www.newexample.com. You need to set up a separate redirect rule for the root domain itself.

2. Precedence of Specific Records:

Wildcard redirects do not override existing DNS records. If you have specific subdomains with defined DNS records, these will take precedence over the wildcard rule. For example, if blog.example.com has its own A record or CNAME record, it will not be affected by a wildcard redirect set up for *.example.com.

3. New Subdomains Override Wildcards:

If you create a new subdomain after setting up a wildcard redirect, the new subdomain’s DNS settings will take precedence over the wildcard rule. This is important for expanding or updating your site without disrupting existing wildcard configurations.

4. Limited Record Type Support:

Wildcard DNS records are not universally applicable to all types of DNS records. They typically support common record types like A, AAAA, CNAME, MX, and URL redirects, but do not apply to NS (Name Server) records. This limitation is crucial for managing domain name server settings, as wildcard redirects cannot be used to redirect DNS lookups.

5. Potential SEO Implications:

From an SEO perspective, indiscriminate use of wildcard redirects can lead to issues. Search engines prefer clear, direct paths to content. Overuse of redirects, especially if they lead to irrelevant or generic pages, can negatively impact user experience and search rankings. It’s essential to ensure that redirects lead users to content that closely matches their original search intent.

6. User Experience Considerations:

While wildcard redirects are efficient, they may not always provide the best user experience. For instance, if old URLs are redirected to a generic homepage rather than a relevant page, it can frustrate users who are looking for specific content. Tailoring redirects to lead users to appropriate content, even if it requires more effort, can significantly enhance user satisfaction.

What about a 301 redirect?

301 redirect

You might think, “How about a 301 redirect?” at this point. Shouldn’t I use this instead? A 301 redirect, on the other hand, is best used when the website address has been permanently changed, such as to a new domain.

It will also be useful if several URLs can be used to visit the same webpage. In such circumstances, one domain is chosen, and the others are redirected. Finally, a 301 redirect is also a smart option if you want to integrate two sites.

A 301, on the other hand, does not take into account things like typos or strange domains. This implies that you may need to use both a 301 and a catch-all to transfer a domain name efficiently.

What about 302 redirects?

The difference between a 302 and 301 is, that a 301 redirect refers to the permanent migration of a page to a different location, 302 redirect refers to temporary migration. Therefore, it does not transfer the link value to the new location. The advantage is that it does not redirect the visitor to the ‘404 not found’ error page but to a genuine website. 

E-commerce sites can use it for out-of-stock products. For example, the 302 redirects may be used to send users to the product category page, where they can look for similar products.

How about .htaccess?

It normally takes some time for search engines to find a 301. This is why Google recommends testing your migration with a single subdomain or directory before moving the entire site.

Incorporating a 301 into the .htaccess file will “inform” search engines that a new link is in place of the old one. Here are several cases in which .htaccess could be useful: 

  • 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

How about meta refresh?

This redirect occurs at the page level and is slower. However, because of the diminished usability and loss of link equity, SEO professionals frequently ignore it. It is distinguished by a five-second flash of text that prompts you to click on a link if you are not redirected within five seconds.

Wildcard SSL certificates

As previously stated, wildcard redirects manage non-existent subdomains so that users can access a valid page regardless of the request. However, for wildcard redirection to work properly, they must be safe so that they do not jeopardize the integrity and security of your website. That is why wildcard SSL certificates are so important.

What is a wildcard SSL certificate?

This certificate ensures that the connection between the user’s internet browser and your website is safe. Furthermore, you can protect an unlimited number of principal subdomains with a single certificate. You’ll save money if you don’t have to get an SSL for every weird subdomain out there.

Here are some additional advantages of using wildcard SSL certificates.

Quick certificate processing

Your SSL certificates will be ready in two days. After domain confirmation, which takes a few minutes, you will have your certificate within two days.

Cost-effective

These certificates are regularly updated to meet the requests of new users. All updates are free of charge. So there’s no need to spend money to get the most recent updates. A trusted website seal, which you can get for free, can help assure your customers that your website is secure.

High compatibility

These certificates are often quite compatible across servers and devices. These SSL certificates are 99.9% compatible.

How to do a wildcard redirect?

Here are a few ways how you can use wildcard redirects.

Using .htaccess for wildcard redirect

This approach is useful when performing large-scale redirects. For example, if you want to redirect a whole domain to another. It allows you to add redirects by manually modifying the .htaccess file.

To access the .htaccess file, do the following steps:

  • Access your cPanel.
  • Then go to Files. Manager of files
  • Select the website’s root folder.
  • You may right-click in the folder and choose “Edit.”

If you do not currently have a .htaccess file, you have to create one. Here’s how to create it:

  • On the top-left side, select “New File.”
  • Give the file a name. Ensure the file is named .htaccess (don’t forget to include the dot at the beginning and write the filename in lowercase).
  • Set the new .htaccess file’s directory to /public HTML/ or the document root of your website.
  • Select ” edit ” if your text editor prompts you with an encoding dialog box.
  • Here are several 301 redirects you can use to achieve various purposes after you access the .htaccess file (or after creating a new one).

Redirecting individual files

To redirect example.com/articles.htm to example.com/blog.htm. The 301 redirect to use is:

Redirect 301 /articles.htm /blog.htm

Redirecting an old domain to a new domain

Example:

From example.co to example.com. It is important to note that doing so will move your entire website. Insert the following code into the example.com .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} www.example.com [NC]
RewriteRule ^(.*)$ http://example.co/$1 [L, R=301,NC]

Redirecting a specific file to another domain

Example:

example.com/articles.htm to example.com/blog.htm. The 301 redirect to use is:

Redirect 301 /articles.htm /blog.htm

Forcing the use of a wWW version

Search engines distinguish example.com and www.example.com as two different websites.

You should choose one and use a 301 redirect to that one. The following code will be used to force the www version:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L, R=301,NC]

All files with a certain extension

Let’s assume you wish to redirect all files ending in.php from example.com/file.php to example.com/file.htm. Use the following code:

RewriteEngine on
RewriteCond %{REQUEST_URI} .php$
RewriteRule ^(.*).php$ /$1.htm [R=301,L]

Forcing the use of a non-WWW version

Use the following code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L, R=301,NC]

Redirecting files to SSL

If you have added an SSL certificate to your website, you should include 301 redirects to transfer all HTTP traffic to HTTPS. Doing so ensures that your users have access to non-duplicate and safe content.

To redirect files to SSL, use the following code:

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

How to do a wildcard redirect using .htaccess in WordPress?

To redirect your WordPress site, you must first enter the .htaccess file. This is how you do it: 

  • Go to the root folder of your WordPress site. You can do this using the File Manager in your cPanel or FTP.
  • Once there, go to your .htaccess file.
  • Before making any changes to your .htaccess file, make a backup.
  • Then you can make the required 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)

How to do a wildcard redirect in cPanel

When you wish to redirect traffic from one domain to another, using cPanel is a great option. This can be done at both the website example.com/about.html to (example.com/about-us/htm) and domain levels (example.com to example.co).

It is important to note that when you establish a redirect in cPanel, a redirect rule is immediately added to the .htaccess file.

Redirecting a full domain to a new one

What you must do is as follows:

  • Log in to your cPanel
  • Navigate to the “Domains” section
  • Select the redirect option. This will take you to the Add Redirect page.
Cpanel>>Domains>>Redirect
Cpanel>>Domains>>Redirect
  • Select “Type” from the dropdown menu
  • Choose between a permanent and temporary redirect
  • Select the next option from the dropdown menu
  • Select the domain to which you wish to redirect
  • You can enter important folder names under the slash (/) area
  • Navigate to the “redirects to” box and enter the address you wish to redirect to
  • Select the desired redirect option (“only redirect with www,” “do not redirect with www,” or “redirect with or without www”)
  • Check the box to create a wildcard redirect
create wildcard redirect in cpanel
create wildcard redirect in Cpanel
  • After the redirected URL, the wildcard contains the file/folder name. Thus example.com/tests.php redirects to example.com/tests.php
  • When you’re finished, tap add
  • The specifics of your reroute will be displayed

How to do a wildcard redirect with Simple 301 Redirects WordPress Plugin

Wildcards are incredibly simple to utilize in Simple 301 Redirects. First, install and activate the plugin to get started. Once activated, navigate to Settings 301 Redirects to begin configuring some 301 redirects:

To create new redirect links for all files in one directory, go to Settings-> 301 Redirects in your WordPress dashboard and tick the ‘Use Wildcards’ checkbox.

Simple 301 Redirects Wildcard redirect
Simple 301 Redirects Wildcard redirect

Use an asterisk ‘‘ after the old dynamic URL includes the old category and another asterisk ” after the new destination dynamic URL. Then, under the Simple 301 Redirects plugin, click the ‘Add New’ button to generate new redirect URLs with Wildcards.

Example:

Request: /old-folder/*
Destination: /wildcard-redirect-everything-to-here/

You can also use the asterisk in the destination to replace whatever it matched in the request if you like. Something like this:

Example:

Request: /old-folder/*
Destination: /one/two/new-folder/*

Or:

Request: /old-folder/*/content/
Destination: /one/two/new-folder/*

That’s how you can easily use Wildcards to generate redirect URLs in Simple 301 Redirects.

A few things to consider

You can achieve a lot of redirection needs with those code snippets, but to keep things neat (and prevent going in circles), consider following these rules when setting up redirects:

  • When possible, avoid “stacking” redirects. This confuses and is not advised for SEO.
  • Before testing, ensure that your hosting and local caches are completely clear. Using a Chrome Incognito window at this time is a good option because your browser will frequently cache redirects behind the scenes, preventing you from seeing changes to existing redirects immediately. Also, check if you use a caching plugin, host-based cache, or Cloudflare cache.
  • If the Redirection plugin causes too many redirect loops, talk to your server about redirecting with .htaccess. The regular expression formatting is almost the same, but by using .htaccess, you can ensure that the annoying redirects are done before the WordPress ones, which generally resolves any outstanding issues.

Conclusion

Moving a website or domain is not a simple task. It is a task that must be completed with caution and strategy to prevent losing visitors and negatively impacting your Google rating. Using wildcard redirects makes this a piece of cake.

They are also useful for rebranding, changing domains, or doing anything else that may cause a redirect. Wildcard SSL certificates will keep your website safe, particularly if you use a wildcard subdomain redirect.