A wildcard redirect is a single rule that redirects many URLs at once by matching a pattern, instead of writing one redirect for every page. The wildcard is the "match anything" part of the rule. It's what you use when you move a whole folder, subdomain, or domain and want every URL underneath it to follow, without listing each one by hand.
This guide explains what a wildcard redirect is, when to use one, and how to set it up with .htaccess or cPanel. If you want the basics of redirects first, start with our guide to redirects.
What is a wildcard redirect?
Say you move everything from /news to /blog. You could write a separate redirect for every article, but that's slow and easy to get wrong. A wildcard redirect handles the whole folder in one rule: /news/anything goes to /blog/anything, keeping the rest of the path intact.
The "wildcard" is usually written as (.*) or *, depending on the tool. It means "match whatever comes next and carry it over to the new location." That's what makes it a catch-all: one rule covers every URL in the folder, including pages you'd forgotten about.
You'll reach for a wildcard redirect in a few common situations:
- Moving a section of your site to a new folder.
- Rebranding to a new domain name.
- Switching to a CMS that uses a different URL structure.
- Forcing every page to the www (or non-www) version, or to HTTPS.
In each case the goal is the same: keep visitors and search engines out of 404 errors, and pass the SEO value of the old URLs on to the new ones.
How to set up a wildcard redirect with .htaccess
The .htaccess file is a configuration file for Apache servers. It controls settings like compression and caching, and it's also where you set up redirects. You can edit it in cPanel's File Manager or from your code editor.
This is the best option for big moves, like redirecting a whole folder or an entire domain. Here are the rules for the most common cases.
Redirect a single file
To send one old URL to one new URL, you don't need a wildcard at all. A plain 301 does it:
Redirect 301 /news.htm /media.htm
Redirect an entire folder
This is the classic wildcard redirect. Say you moved your /news section to /blog and kept the same structure underneath. This rule moves everything in one go:
RewriteEngine on
RewriteRule ^news/(.*)$ /blog/$1 [L,NC,R=301]
The (.*) captures whatever follows /news/, and $1 drops it back into the new path. So /news/article redirects to /blog/article. The R=301 flag makes it a permanent redirect.
Redirect an old domain to a new one
When you move your whole site to a new domain, this rule sends every URL to the matching URL on the new domain. Add it to the old domain's .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com [NC]
RewriteRule ^(.*)$ https://www.new-domain.com/$1 [L,R=301,NC]
Force the www or non-www version
Search engines can treat example.com and www.example.com as two separate sites, which splits your ranking signals. Pick one version and redirect the other. To force the www version:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
To force the non-www version instead:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NC]
Force HTTPS
If you've added an SSL certificate, redirect all HTTP traffic to HTTPS so visitors always land on the secure version and you avoid duplicate URLs:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
301 or 302: which status code?
Every redirect returns a status code, and the one you choose matters for SEO. Use a 301 when the move is permanent. It tells search engines the new URL is the one to keep, and it passes the old page's ranking value to the new page. Only use a 302 for a temporary move you plan to reverse. When in doubt on a real move, use a 301. There's more on status codes here.
How to set up a redirect in cPanel
If you'd rather not touch .htaccess directly, cPanel has a Redirects tool that writes the rule for you. It's handy for domain-level and page-level redirects.
Redirect a full domain
- Log in to cPanel.
- Open the "Domains" section and click "Redirects".

- Set the "Type" to Permanent (301).
- Choose the domain you want to redirect.

- Enter the address you want to redirect to.
- Choose how to handle www (redirect with www, without www, or either).
- Check the "Wild Card Redirect" box so paths carry over, so
example.com/pageredirects tonew-example.com/page. - Click "Add".
cPanel writes the matching rule into your .htaccess automatically.
Edit .htaccess in cPanel File Manager
To edit the file yourself:
- In cPanel, open Files, then File Manager.

- Open your website's root folder (usually
public_html). - Right-click .htaccess and choose "Edit".

If there's no .htaccess file yet, create one: click "New File", name it .htaccess (keep the leading dot and lowercase), and save it in your root folder. Then add the rules from above.
Tips for a clean redirect
A few habits keep your redirects fast and problem-free:
- Don't chain redirects. If A points to B and B points to C, send A straight to C. Chains are slower and waste crawl budget.
- Clear your caches before testing. Browsers, caching plugins, and services like Cloudflare all cache redirects. Test in an incognito window so you see the live result.
- Watch for redirect loops. If a rule sends a page back to itself, you'll get a loop. Double-check that your source and destination patterns don't overlap.
Wrapping up
Moving a site or a section is risky if you leave URLs behind, but a wildcard redirect makes it manageable. One rule redirects a whole folder, domain, or protocol, so visitors never hit a dead page and your rankings carry across. Set it up with a 301, test it with your caches cleared, then check your redirects are all resolving cleanly.