Wildcard Redirects: How They Work, With Setup for 5 Platforms

Key takeaways
A wildcard redirect is one rule that matches many URLs by pattern, such as everything under /old-blog/ or every subdomain of old-brand.com, and sends each one to a new address, usually keeping the rest of the path. You set it where the request is answered: in .htaccess on Apache, a server block on NGINX, a redirect rule in Cloudflare, Webflow's 301 redirects (with capture groups), or a registrar's catch-all subdomain record such as Namecheap's. A wildcard DNS record alone doesn't redirect anything. Use 301 or 308 for permanent moves, point each URL straight at its final page, put exceptions above the catch-all, and keep the rules for at least a year after a migration.
A wildcard redirect is a single rule that matches many URLs by pattern and sends them somewhere else. Instead of listing 4,000 old addresses one by one, you write something like “everything under /blog/ goes to the same path on the new domain” and let the server do the rest. This guide explains the difference between DNS wildcards and wildcard redirects, then shows working setups for Apache, NGINX, Cloudflare, Webflow and Namecheap, the SEO mistakes that cost rankings, and when a managed redirect layer is the simpler choice.
What a wildcard redirect actually is#
The word “wildcard” covers three different things, and search results mix them freely.
Wildcard (pattern) redirects. A rule with a placeholder. The placeholder can stand for “any characters after this point” (a prefix match), “any characters before this point” (a suffix match), or a captured segment that is reused in the destination. Typical examples: /old-blog/* to /blog/*, or *.olddomain.com to newdomain.com.
Wildcard DNS records. A record with an asterisk in the leftmost label, such as *.example.com, answers queries for subdomains that have no record of their own. AWS documents how asterisks work in record names[1], and the key point for this topic is that DNS only decides which server answers. The redirect itself is an HTTP operation that happens after DNS resolution, on the server that receives the request.
Wildcard prohibition at the registry level. The third use is about top-level domain registries: operators are barred from synthesizing responses for non-existent domains. That is a rule for registries, not something you configure on your own site.
So a complete wildcard setup for subdomains usually needs both layers: a wildcard DNS record so every subdomain reaches your server, and a server-side rule that decides where each request should go.

The patterns you will actually use#
Most real-world needs fall into six patterns.
| Pattern | Example source | Example destination | Typical use |
|---|---|---|---|
| Prefix, path preserved | /old/* | /new/* | Renamed section |
| Prefix, path dropped | /discontinued/* | /products/ | Retired category with one landing page |
| Suffix match | /resources/ | Moved downloads | |
| Subdomain wildcard | *.old-brand.com | new-brand.com | Rebrand |
| Whole domain, path preserved | old.com/* | new.com/* | Domain change |
| Regex with capture | /blog/(\d{4})/(.*) | /articles/$2 | Dropping dates from URLs |
The difference between the first two rows is the one that matters most. Preserving the path keeps one-to-one relevance, which is what you want when the new site mirrors the old one. Dropping the path is only right when no equivalent pages exist.
Wildcard redirects on Apache (.htaccess)#
A common question is how to redirect everything after a certain path through .htaccess. On Apache, that is the job of mod_rewrite. The Apache mod_rewrite documentation[2] describes RewriteRule and the flags that go with it, including R for redirect.
A prefix redirect that keeps the rest of the path:
<code class="language-apache">RewriteEngine On
RewriteRule ^old-section/(.*)$ /new-section/$1 [R=301,L]
</code>The parentheses capture everything after old-section/, and $1 inserts it into the destination. L stops further rule processing, which prevents accidental double matches.
A whole-domain redirect that keeps paths and query strings:
<code class="language-apache">RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [R=301,L]
</code>A few things trip people up:
- Order matters. Rules run top to bottom. Put specific rules above general ones, or the catch-all swallows everything.
- Escape dots. An unescaped
.in a regex matches any character. - Test with a 302 first. Browsers cache 301s aggressively. Use
R=302while testing, then switch to 301 when the rule behaves. - Mind the server.
.htaccessworks on Apache only. If your host runs NGINX, the file is ignored.
Wildcard redirects on NGINX#
NGINX handles hostnames through server_name. The NGINX web server guide[3] explains that a server name can be an exact name, a wildcard with an asterisk at the start or end, or a regular expression, and that exact names win over wildcards when several match.
Redirect every subdomain of an old domain to the new one:
<code class="language-nginx">server {
listen 80;
server_name .old-domain.com;
return 301 https://new-domain.com$request_uri;
}
</code>The leading dot matches both old-domain.com and any subdomain. $request_uri carries the original path and query string, so deep links survive.
For a path prefix inside a site:
<code class="language-nginx">location ~ ^/old-section/(.*)$ {
return 301 /new-section/$1;
}
</code>Prefer return over rewrite for simple redirects. It is clearer and cheaper to evaluate.
Wildcard redirects in Cloudflare#
If the domain already runs through Cloudflare, you don't need regex. Redirect rules have a Wildcard pattern option: each * matches any characters (including none), and ${1}, ${2} and so on reuse what each * captured, numbered from left to right, including the * in http*. Cloudflare's Single Redirects settings page[4] has the full numbering rules. The hostname must be proxied through Cloudflare (orange cloud) for the rule to fire.
- In the Cloudflare dashboard, open the domain and go to Rules > Overview.
- Select Create rule, then Redirect Rule.
- Under When incoming requests match, choose Wildcard pattern.
- In Request URL, enter the pattern, for example http*://old-domain.com/blog/*.
- In Target URL, enter the destination with its reference, for example https://new-domain.com/articles/${2} (${1} is the * in http*).
- Set Status code to 301 for a permanent move. Cloudflare suggests 302 or 307 while you test, because browsers cache 301s.
- Select Deploy, then check the rule's position: Cloudflare applies the first matching rule, so specific rules go above general ones.
Query strings: when the Request URL ends with * and the Target URL ends with that reference, the query string carries over even with Preserve query string off, as Cloudflare's dashboard guide and settings page[5] explain. To drop it, use a custom filter expression instead.
Wildcard redirects in Webflow#
Webflow calls them capture groups. You write (.*) in the old path and %1, %2 in the new one, under Site settings > Publishing > 301 redirects. According to Webflow's redirect guide[6], 301 redirects need a paid Site plan (or a paid Workspace plan), they are relative to the root domain (a localized /es/ path needs its own rule), and Webflow runs them in the order they were added, oldest first, so add specific rules before a broad wildcard. Special characters in the old path, such as ?, =, - and _, must be escaped with %.
- Go to Site settings > Publishing > 301 redirects.
- In Old path, enter the folder with a capture group, for example /oldfolder/(.*).
- In Redirect to path, enter the new structure with its reference, for example /new-folder/%1.
- Click Add redirect path.
- Publish the site.
To send a whole folder to one page instead, leave out the reference: /collections/(.*) to /collections. Webflow's own tip is to use wildcard rules where you can, because every rule adds to the file browsers download, and it recommends staying around 1,000 rules.
Wildcard redirects in Namecheap#
In Namecheap, a wildcard redirect is a catch-all for subdomains: one record answers every subdomain that has no record of its own, such as anything.yourdomain.com. It works at the subdomain level, not as a path pattern like the Apache, NGINX or Cloudflare rules above, and it needs the domain on Namecheap's own DNS. The steps below follow Namecheap's URL redirect guide[7].
- Sign in and select Manage next to the domain.
- Open the Advanced DNS tab and select Add New Record.
- Choose URL Redirect Record as the type.
- Enter * in Host.
- Enter the destination URL in Value.
- Change the redirect type from Unmasked to Permanent (301) if the move is permanent.
- Save, then delete any A, CNAME, ALIAS or other URL Redirect records that conflict with the same host.
The Domain tab has a shortcut for the same thing: Redirect Domain > Add Wildcard redirect. Namecheap says changes take up to 30 minutes, and that redirecting from an https:// address needs an SSL certificate installed on that domain, so open https://anything.yourdomain.com as well as the http:// version before you call it done.
Is your redirect working? Enter your domain. You'll see the status code (301 or 302), where it lands, whether HTTPS is valid, and how fast it answers from Washington, Frankfurt and Tokyo, ranked against every redirect tested in the last 7 days.
Test my redirectChoosing the status code#
The code you return tells browsers and search engines how to treat the move.
- 301 (Moved Permanently) and 308 (Permanent Redirect) say the resource has a new permanent address. The MDN reference for 301[8] describes browsers following the
Locationheader automatically. - 302 and 307 are temporary. Use them for A/B tests, short promotions or maintenance pages.
Google’s guidance is that permanent redirects help consolidate duplicate URLs and signal that the new URL should be indexed[9], while temporary redirects keep the source page’s indexing priority. If the change is long-term, use a permanent code. A wildcard rule left on 302 after a migration is a quiet, common error.
What RedirHub traffic shows about permanent and temporary codes#
Across the redirect requests RedirHub's edge served in a sample from October 2026, about 4 in 10 came from bots. Of the requests from people, about 82 in 100 received a 301 or 308, about 1 in 100 a 302 or 307, and fewer than 1 in 1,000 an error (RedirHub platform data, October 2026).
| Response to a person's request | Share of requests |
|---|---|
| 301 or 308 (permanent) | About 82% |
| 302 or 307 (temporary) | About 1% |
| 4xx or 5xx (error) | Under 0.1% |
Permanent codes dominate, so a wildcard rule still on a temporary code after a migration stands out as the exception to audit. The shares count people only (bots excluded), come from the redirect access log rather than a survey, and leave out the very largest accounts so that no single customer skews them. On RedirHub, domain redirects with 301, 302, 307 and 308 are included on Core, Pro and Enterprise, while wildcard subdomain redirects are included on Pro and Enterprise only.
SEO mistakes that wildcard rules make easy#
Because one rule touches thousands of URLs, one wrong rule damages thousands of pages at once.
Sending everything to the home page#
The lazy catch-all, /* to /, looks tidy and loses relevance. A visitor who clicked a link to a specific guide lands on a generic home page and leaves. Search engines may also treat mass redirects to an irrelevant page as a soft 404. Redirect to the closest equivalent, and use a broader parent category only where no equivalent exists.
Creating chains#
Say http://old.com/page redirects to https://old.com/page, which redirects to https://www.old.com/page, which redirects to https://new.com/page. That is three hops. Google’s documentation notes that Googlebot can follow a limited number of hops, and that direct redirects are preferred[9] because chains add latency and can slow indexing. Write the rule so the first response already points to the final URL, with protocol, host and path all corrected at once.
Forgetting the query string and fragments#
Campaign parameters such as UTM tags often ride along on old links. Check whether your rule preserves the query string where you want it. In Apache, a redirect to an absolute URL carries the original query string unless you tell it otherwise, as the Apache documentation explains. In NGINX, $request_uri includes it, while $uri does not.
Mixing up www and non-www#
Pick one canonical host and redirect the other to it. Google’s guidance on consolidating duplicate URLs[10] lists redirects as a strong signal of your preferred version, and either choice is fine as long as you stay consistent. If you need a walkthrough, our note on redirecting non-www to www covers it.
Removing rules too early#
Google says redirects may be treated as a canonicalization signal, not an absolute command, and that it can still choose a different canonical based on other factors, as its canonicalization documentation[11] explains. In practice, keep permanent redirects in place for at least a year after a move, and longer for URLs that still earn external links.
A safe process for a wildcard migration#
- Inventory the old URLs. Pull them from your sitemap, server logs, analytics and a crawl. Google’s site move documentation[12] stresses mapping every old URL to its new home.
- Group them by pattern. Most sites collapse into a handful of wildcard rules plus a smaller list of one-off exceptions.
- Write exceptions first. Individual mappings go above the wildcard rules so they win.
- Test against real URLs. Run a sample of several hundred old URLs, including the oddest ones, and check status code, final destination and number of hops. A redirect checker shows each hop and status code for a single URL, and the redirect speed test adds whether HTTPS is valid and how fast the redirect answers.
- Launch with permanent codes. Switch from 302 to 301 once the tests pass.
- Monitor. Watch crawl errors, 404s and traffic by section for weeks. Fix gaps with new rules, not by editing old ones in a hurry.
Google also notes that large sites can move in sections to test the effect, while smaller sites often do better moving everything at once. For planning the domain side, our SEO domain change guide covers what to check before and after the switch.
Where server files stop being practical#
Editing .htaccess or an NGINX config is fine for one site you control. It gets painful when:
- You own dozens of domains, some parked, some legacy, some bought for a campaign.
- Marketing needs to change a destination, but changes require a developer and a deploy.
- Your site runs on a platform with no access to server configuration.
- Redirect rules live in four places (CMS, CDN, server, registrar) and nobody knows which one wins.
The ordering also matters. As MDN explains[13], redirection is triggered by the server sending a 3xx response with a Location header, so it happens before any page content is sent. Client-side tricks like JavaScript or meta refresh are a last resort when you can’t reach the server layer. A dedicated redirect layer keeps you at the right level without requiring server access.
Speed is the other cost of leaving the server layer, and it is small: RedirHub's median time to first byte was 15 ms, against 12 ms for the fastest of 28 providers measured, Fastly and Amazon CloudFront, from Washington, D.C., Frankfurt and Tokyo (RedirHub redirect speed benchmark, 24 November to 1 December 2026[14]).
Our perspective#

Most redirect trouble we see is not about syntax. It is about ownership. A rule gets written once by whoever was on the project, lives in a config file, and years later nobody remembers why /promo/* points where it does. Then a domain expires, a printed brochure or QR code keeps sending people to a dead page, and the fix needs a ticket.
We built RedirHub around the idea that links and redirects should sit on your own domain and stay under your control, with SSL handled for you, rather than depend on a shared shortener or a pile of server files. Our advice for wildcard rules is the same whichever tool you use: write the narrowest pattern that does the job, point it straight at the final URL, keep a list of exceptions, and review the rules on a schedule. Treat redirects as long-term assets, because the links in the wild will outlive your current site design.
Managing wildcard and domain redirects without config files#
RedirHub moves the rule off your server and onto the domain itself. Point the old domain at RedirHub and every URL on it matches by default; choose Keep the path and old-domain.com/any/page lands on new-domain.com/any/page, which is the most common wildcard rule, with no pattern to write. Root and www count as one domain, and automatic HTTPS covers both, issued and renewed for you, even when the old domain has no hosting left.
When the new site has a different structure, treat it as a website migration and map each old URL to its own new page instead of one pattern, loading the list with bulk CSV import on any plan. If you hold a portfolio of parked domains, each one becomes a domain redirect with the same settings, managed from one Links page.
Wildcard subdomain redirects (a catch-all for *.old-domain.com) are on Pro and Enterprise only. With Integration Mode, where your own CDN, app or CMS serves the rules without a DNS change, wildcard domains aren't supported, so a subdomain catch-all needs the DNS connection.
Set up a wildcard-style domain redirect in RedirHub#
- Select Create, then Domain Redirect.
- In Redirect from, enter old-domain.com.
- In Redirect to, enter https://new-domain.com.
- Under Paths, choose Keep the path (or Everything to one URL to send every page to a single address).
- Leave Redirect type on 301 · Permanent, or open More types for 302, 307, 308 or a frame redirect.
- Select Create redirect.
- Under Connect DNS, choose Manual, add the records it shows for the root and www at your DNS provider, then select I've made the changes.
- Open a few old deep URLs and check that each lands on the matching new page.
| Apache or NGINX rule | Cloudflare redirect rule | Namecheap wildcard record | RedirHub domain redirect | |
|---|---|---|---|---|
| What it matches | Any path or host pattern you write | URL patterns with *, including subdomains | Subdomains that have no record of their own | Every path on the domain (keep or drop the path); subdomain catch-all on Pro and Enterprise |
| What changes in DNS | Nothing, if the domain already points at your server | The hostname must be proxied by Cloudflare | The domain must use Namecheap DNS | Only the root and www records; nameservers and email stay where they are |
| HTTPS on the old domain | Your own certificate | Cloudflare's edge certificate | Needs a certificate installed on the domain | Issued and renewed automatically for root and www |
| Who can change it | Whoever can edit and deploy the server config | Anyone with access to the Cloudflare zone | The Namecheap account holder | Your team in the dashboard, or by API, MCP or CSV import |
Beyond the rule itself, a RedirHub domain redirect gives you:
- Redirects served from 130 global edge locations (PoPs), close to each visitor.
- 301, 302, 307, 308 and frame redirects, with path and query parameter forwarding on every plan.
- Clicks and unique visitors with bots filtered out, the top links per domain, and a 404 report that lists old URLs your rules still miss, with a one-click redirect to a suggested page.
- DNS re-checked every 10 minutes, and several source domains on one redirect.
If you run one site on Apache, NGINX, Cloudflare or Webflow and someone can edit its config, a rule there is free and fast, and it is the right place for redirects within that site. RedirHub earns its place when the rules span many domains, need HTTPS on domains with no hosting, or have to be changed by people who don't deploy code. Plans start at $49/month (Core); Pro, which adds wildcard subdomain redirects, is $119/month with a 14-day free trial.
Quick reference: wildcard DNS versus wildcard redirect#
| Question | Wildcard DNS record | Wildcard redirect |
|---|---|---|
| Layer | DNS | HTTP (server, CDN or redirect service) |
| What it does | Answers for subdomains with no record | Sends a 3xx response to a new URL |
| Changes the address in the browser | No | Yes |
| Needed for catching any subdomain | Yes | Yes, to decide the destination |
| Where you set it | DNS provider | Server config, CMS or redirect platform |
One more DNS detail for multi-domain setups: a CNAME can’t sit at the zone apex (the bare example.com), while some providers offer alias-style records that can. AWS describes this in its comparison of alias and non-alias records[15]. If you point bare domains at a redirect service, check which record type your DNS provider supports at the apex.
Worked example: a rebrand with three subdomains#
Imagine a company moving from acme-tools.com to acme.com. It has a blog, a support site on help.acme-tools.com, and a few regional subdomains such as uk.acme-tools.com.
A clean plan looks like this:
- Add a wildcard DNS record on the old domain so any subdomain, including ones nobody remembers, reaches the redirect layer.
- Create explicit rules first:
help.acme-tools.com/*tosupport.acme.com/*, anduk.acme-tools.com/*toacme.com/uk/*. - Add a general rule:
*.acme-tools.com/*toacme.com/*, as a fallback. - Add the root rule:
acme-tools.com/*toacme.com/*. - Return 301 for all of them, with HTTPS in the destination so there is one hop.
- Test 200 old URLs from the sitemap and from analytics, then check them again after a week.
The explicit rules protect the sections with different structures, and the fallback catches strays. Without the order, the fallback would flatten the support site into the main domain’s paths, where nothing matches.
Manage wildcard redirects without config files
Point your old domain at RedirHub, add wildcard subdomain redirects on Pro, and change destinations without touching a server.
See domain redirectsSources
- [1]Amazon Route 53: DNS domain name format
- [2]Apache HTTP Server: mod_rewrite
- [3]NGINX: configuring a web server
- [4]Cloudflare docs: Single Redirects settings
- [5]Cloudflare docs: create a redirect rule in the dashboard
- [6]Webflow Help: how do I set up redirects in Webflow?
- [7]Namecheap Knowledgebase: how to redirect a URL for a domain
- [8]MDN: 301 Moved Permanently
- [9]Google Search Central: Redirects and Google Search
- [10]Google Search Central: consolidate duplicate URLs
- [11]Google Search Central: canonicalization
- [12]Google Search Central: site moves and migrations
- [13]MDN: Redirections in HTTP
- [14]RedirHub redirect speed benchmark, 24 November to 1 December 2026
- [15]Amazon Route 53: choosing alias or non-alias records
Frequently asked questions
A wildcard redirect is one rule that matches a group of URLs by pattern, such as /old-blog/* or *.old-brand.com, and sends each of them to a new address, often keeping the rest of the path. It replaces hundreds or thousands of one-to-one redirects. A wildcard DNS record is different: it only makes unknown subdomains resolve to a server.
In Namecheap, open Manage next to the domain, go to Advanced DNS, add a URL Redirect Record with * as the host and the destination URL as the value, and set the type to Permanent (301) if the move is permanent. It catches subdomains that have no record of their own; it is not a path pattern. Namecheap notes that redirecting from an https:// address needs a certificate installed on that domain.
Go to Rules > Overview, select Create rule > Redirect Rule, choose Wildcard pattern, enter a Request URL such as http*://old-domain.com/blog/* and a Target URL such as https://new-domain.com/articles/${2}, pick 301, and deploy. The hostname must be proxied through Cloudflare.
Yes, through capture groups in Site settings > Publishing > 301 redirects: write (.*) in the old path and %1 in the new path, for example /oldfolder/(.*) to /new-folder/%1. 301 redirects need a paid Site or Workspace plan, and Webflow runs rules oldest first, so add specific rules before broad ones.
No. A wildcard DNS record only makes unknown subdomains resolve to a server. A wildcard redirect is an HTTP rule that tells visitors and crawlers to go to a different URL. Many subdomain migrations use both.
Not when they map old pages to relevant new ones with a permanent code and no chains. They hurt when they send everything to the home page, stay on a temporary code, or are removed after a few weeks. Google’s documentation recommends permanent redirects for permanent moves.
Use 301 or 308 if the move is permanent, such as a domain change or restructure. Use 302 or 307 only for short-term cases like a campaign or maintenance. Test with a temporary code, then switch to the permanent one when everything checks out.
At least a year for a site migration, so search engines have time to reprocess the content. Keep them longer if old URLs still receive traffic or external links, since removing the rule would turn those visits into errors.

Leo Astarothman is the Brand & Content Lead at RedirHub, where he shapes the company's visual identity, educational content, product experiences, and marketing strategies. He also specializes in system design. Simplifying complex redirect infrastructure into practical resources, product experiences, and campaigns that help businesses understand and adopt modern redirect management.
Related Articles
View All Articles


