Free tools Windows power users keep installed
One-click scans. No signup required.
You can put many individual RewriteRule redirects in an Apache 2.4 .htaccess file, but you cannot declare a RewriteMap there. If you control only .htaccess, use an ordered list of rules; for a large mapping file, ask your host or administrator whether they can configure the map in the server or virtual-host configuration. Build and verify redirects as temporary 302s first, then change them to permanent 301s.
Choose the right approach for bulk 301 redirects in .htaccess
The key difference is where Apache permits the configuration. RewriteRule directives can be used in .htaccess when the server allows the necessary overrides. A RewriteMap declaration cannot be placed in .htaccess or a <Directory> block; it must be declared in server or virtual-host configuration. Apache documents this restriction in its Per-directory Rewrites documentation.
As an Amazon Associate I earn from qualifying purchases.
| Approach | Configuration access | Best fit | Trade-offs |
|---|---|---|---|
Individual RewriteRule entries |
.htaccess access, with suitable server permissions |
A list that is practical to review and maintain as rules | Each mapping is explicit, but the file grows with the list; matching and rule order need careful review. |
RewriteMap lookup |
Server or virtual-host configuration access is required to declare the map | A large mapping list maintained as a separate lookup source | The administrator must configure the map; the map declaration itself will not work in .htaccess. |
Apache’s documentation does not set a universal safe number of redirects or a quantified performance cutoff for choosing between these approaches. Make the choice based on access, maintainability, and the ability to test and roll back safely.
Confirm Apache prerequisites
Before editing rules, confirm the server has mod_rewrite enabled and that its configuration permits the directives in your directory. Apache’s example uses AllowOverride FileInfo; the actual policy is set by the server administrator. Per-directory rewriting also requires Options FollowSymLinks or Options SymLinksIfOwnerMatch. See Apache’s per-directory rewrite requirements.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
- If the file is ignored or causes a server error, ask the host or administrator to confirm module availability and override permissions.
- Do not add an
Optionsdirective to.htaccessunless your hosting configuration permits it. - If you do not have server or virtual-host access but need a lookup map, ask the administrator whether they can define it for you.
How do I redirect multiple URLs in .htaccess?
Start with a one-to-one inventory, then write a rule for each old path. In per-directory context, Apache removes the directory prefix and leading slash before testing a RewriteRule pattern. A rule in /app/.htaccess sees a request for /app/products/widget as products/widget, not /app/products/widget. This is why copying a server-level rule pattern directly into .htaccess can miss its target. Apache explains the context difference in its per-directory rewrite guide.
1. Prepare and review the mapping list
- Back up the current
.htaccessfile so you can restore it if needed. - Make a list pairing each old path with its intended destination. Decide consistently whether paths include a trailing slash, and normalize them to that convention.
- Remove duplicate old paths and check that each destination is the final intended URL, rather than another URL that redirects again.
- Check that mappings do not send a URL back to itself or create a cycle, and consider how query strings should behave for each old URL.
2. Add a small batch of rules
A RewriteRule consists of a pattern, a substitution, and optional flags. The following illustrative pattern redirects one path from the directory containing the .htaccess file to an absolute destination. Adapt both paths to your site; it is not a host-specific tested configuration.
Rank #2
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
RewriteEngine On
RewriteRule ^old-page/?$ https://www.example.com/new-page [R=302,L]
The pattern has no leading slash because this is per-directory context. [R=302] requests an external temporary redirect, while [L] stops processing the current rule pass. The destination is an absolute URL, so RewriteBase does not affect it. For a relative substitution, RewriteBase can affect how Apache resolves that substitution; it does not affect substitutions beginning with / or an absolute URL. See Apache’s per-directory rewriting notes and rewrite flags reference.
For multiple mappings, add one specific rule per old path, for example:
RewriteEngine On
RewriteRule ^old-page/?$ https://www.example.com/new-page [R=302,L]
RewriteRule ^old-category/item/?$ https://www.example.com/catalog/item [R=302,L]
Put specific paths before broader patterns so a general rule does not capture a URL that has its own destination. Use an external redirect when the browser must request a different URL; an internal rewrite changes how Apache serves the request without directing the browser to a new address.
3. Test the temporary redirects
- Save the file and test each old URL with a request tool or your browser’s network panel. Confirm the response is a redirect and that its
Locationpoints to the intended destination. - Check representative paths that should not match, as well as every mapping in the list. Look for unintended matches, redirect loops, extra hops, and query-string changes.
- If a substitution causes Apache to process per-directory rules again, review the pattern and rule order.
[L]ends the current pass, but it does not necessarily prevent another per-directory pass. Apache documents possible looping;[END]can stop further per-directory processing in supported contexts. Consult the per-directory rewrite documentation before using it.
Only after the destinations and response behavior are correct should you change the temporary flag to a permanent redirect. A 301 can be cached by browsers indefinitely, and search engines may take days or weeks to recrawl an incorrect redirect. Apache describes this risk in its per-directory rewrite guidance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How can I redirect a list of old URLs to new URLs?
If the list is manageable as explicit rules, keep the mappings in .htaccess and review them alongside the URL inventory. If it is more maintainable as a lookup file, ask an administrator to declare a RewriteMap in server or virtual-host configuration; you can then use a configured map from per-directory rules, but cannot declare the map itself in .htaccess. Do not paste a RewriteMap declaration into the file and expect it to work.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteDo not build redirect destinations from unvalidated user input. Apache warns that an untrusted value used to assemble a redirect URL can let an attacker send visitors to a destination they control. Keep destinations fixed in reviewed rules or validate dynamic values against an allowed set; see Apache’s rewrite security guidance.
Best Value
- These are the words in Charlotte's web, high in the barn
- Her spiderweb tells of her feelings for a little pig named Wilbur, as well as the feelings of a little girl named Fern … who loves Wilbur, too
- Their love has been shared by millions of readers
Move from 302 to 301 and monitor
After the 302 tests pass, change the redirect flag to [R=301,L] for the mappings intended to be permanent. Change only the reviewed rules, retain the backup, and check the live URLs again after deployment. If redirects behave unexpectedly, restore the backup or correct the rules promptly; clients and search engines may retain the permanent response after it has been seen.
Apache’s rewrite trace logging can help diagnose matching and substitution, but keep high trace levels temporary: Apache warns that they can slow the server and generate extensive logs. Use the hosting provider’s supported logging process rather than enabling verbose logging indefinitely.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problems




