How to redirect a whole folder of URLs in WordPress
WordPress has two ways to redirect a whole folder, and they do different things. A Starts With rule in Hydrogen SEO → Redirections sends every URL under a path to one target page. A server pattern rule, RedirectMatch on Apache or rewrite on nginx, moves each URL to the same slug under a new path.
Pick by asking one question: do the old pages still exist somewhere? If a section was renamed, each old URL has a matching new one and needs the pattern rule. If a section was retired, everything can point at the single page that replaced it.
Step by step
1. Map what is under the path
List the URLs that begin with the prefix before you write a rule. Open the relevant sitemap, or filter Search Console's Performance → Pages by "URLs containing" the prefix. You are checking two things: which pages earn traffic, and whether anything unrelated shares the first characters. A rule for /shop also catches /shopping-guide/.
2. One target for everything: a Starts With rule
Use this when a section is gone, for example a discontinued /events-2023/ programme that now lives on one summary page.
- Open Hydrogen SEO → Redirections and click Add New.
- In From URL, enter the path prefix, such as
/events-2023/. Enter the path only, not the domain. - Set Match Type to Starts With.
- In To URL, enter the replacement page, such as
/events/. - Choose 301 - Permanent Redirect, leave Enable this redirection on and click Create.
Every request whose path begins with that text now gets a 301 to /events/. The plugin ignores leading and trailing slashes when it compares paths, so /events-2023/ and /events-2023 behave the same, and the rule also matches /events-2023-recap/. If a URL like that must keep working, give it a different slug first or use the server rule below with an anchored pattern.
3. Same slugs under a new path: Apache
Use this when /blog/ became /articles/ and every post kept its slug. In .htaccess, above # BEGIN WordPress:
RedirectMatch 301 ^/blog/(.*)$ /articles/$1
(.*) captures whatever follows the prefix and $1 puts it back, so /blog/espresso-guide/ goes to /articles/espresso-guide/ and /blog/page/3/ to /articles/page/3/. The ^ and the slash after blog stop the rule matching /blogging-tips/.
4. Same slugs under a new path: nginx
Inside the server block:
rewrite ^/blog/(.*)$ /articles/$1 permanent;
permanent sends a 301. Reload nginx after editing. On managed hosts with no config access, look for a redirects panel that accepts regular expressions or wildcards, where the same pattern usually works.
5. Carve out exceptions
Sometimes most of a folder moves and a few URLs go elsewhere. On the server, put the specific rule before the pattern, since the first match is used:
Redirect 301 /blog/pricing-update/ https://example.com/pricing/
RedirectMatch 301 ^/blog/(.*)$ /articles/$1
Server rules run before WordPress, so they also take priority over any rule saved in the plugin. Avoid defining the same source in both places. It works, but the next person to edit redirects will only look in one of them.
6. Test more than one URL
for p in /blog/ /blog/espresso-guide/ /blog/page/3/ /blogging-tips/; do
curl -sI "https://example.com$p" | grep -iE "^HTTP|^location"; echo
done
The first three should show a single 301 to the right place. The last, a URL that merely looks similar, should be untouched. Follow one redirect to its target and confirm the target answers 200 and not another redirect.
7. Update links and the sitemap
Fix internal links and menu items that still use the old prefix so visitors skip the redirect. The XML sitemap needs no edit when the content moved inside WordPress, because it lists current permalinks. After a few weeks, check the 404 Monitor under Hydrogen SEO → 404 Monitor for stray requests under the old path that your rule missed.
Do not send a live section to one page
A Starts With rule that points fifty existing articles at a single hub page throws away fifty pages' worth of relevance. Google documents that a redirect to a page that is not a real replacement may be treated as a soft 404. Use the one-target rule only when the content behind those URLs is truly gone, and prefer a hub that explains what replaced it over the homepage.
Query strings and file requests
Plugin rules match on the path, and the redirect goes to the target exactly as typed, so a query string on the old URL is not carried over. Apache's RedirectMatch and nginx's rewrite keep the query string by default. Requests for real files, such as PDFs under /wp-content/uploads/old-brochures/, are served by the web server without loading WordPress, so only a server rule can redirect those.
Common questions
Can I use wildcards in WordPress redirects?
Hydrogen SEO offers Contains, Starts With and Ends With matching, which cover most wildcard cases with one target. For rules that reuse part of the old URL in the new one, use a server regex rule.
Should folder redirects be 301 or 302?
301 for a permanent move or removal. Use 302 only while testing, then switch the rule to 301 once the targets are confirmed.
Will a folder redirect slow my site?
No. One pattern rule is cheaper than hundreds of single rules, and a server-level rule answers before WordPress loads.