DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Bulk 301 Redirects in .htaccess: A Step-by-Step Guide

Add multiple Apache redirects safely: prepare the old-to-new URL list, write per-directory RewriteRule entries, test them as 302s, then make verified redirects permanent.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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
Sale
HTML and CSS: Design and Build Websites
  • 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 Options directive to .htaccess unless 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

  1. Back up the current .htaccess file so you can restore it if needed.
  2. 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.
  3. Remove duplicate old paths and check that each destination is the final intended URL, rather than another URL that redirects again.
  4. 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
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

  1. 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 Location points to the intended destination.
  2. 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.
  3. 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.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do 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
Sale
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
  • 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

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.94
SaleBestseller No. 2
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 5
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
Charlotte's Web: A Newbery Honor Award Winner – The Beloved Classic Novel About a Pig, a Spider, and the Power of Friendship
These are the words in Charlotte's web, high in the barn; Their love has been shared by millions of readers
$6.13

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.