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
VGSources
Blog

How to Fix .htaccess Rewrite Rules Not Working in Apache

A practical Apache 2.4 guide to diagnosing ignored .htaccess rules, bad per-directory patterns, AH00670 errors, RewriteBase issues, loops, and stale 301 redirects.
WorldApache Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If Apache appears to ignore your .htaccess RewriteRule, start with the server configuration rather than the regular expression. The usual causes are an AllowOverride policy that prevents Apache from reading the file, a missing mod_rewrite engine, a leading slash in a per-directory pattern, disabled symbolic-link options, an incorrect relative substitution base, rule ordering, or a cached permanent redirect. Work through the checks below in order; each one either fixes the request or narrows the failure to a specific layer.

Use the symptom to choose your first check

Different failures point to different parts of Apache’s request processing. Identify the closest symptom before changing several directives at once.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
What you see Most likely area First action
The request behaves exactly as if no rule exists Apache is not reading the file, the file is in the wrong directory, or the rewrite engine is off Verify the active DocumentRoot, the matching <Directory> block, AllowOverride, and RewriteEngine On
A rule never matches, but there is no server error Per-directory pattern syntax or a failed condition Remove the leading slash from the pattern and inspect every RewriteCond
Apache returns HTTP 500 and the error log mentions AH00670 Symbolic-link options are not permitted Enable Options FollowSymLinks or Options SymLinksIfOwnerMatch in an allowed context
An internal rewrite lands at the wrong URL or a subdirectory installation fails Relative substitution has the wrong URL base Evaluate whether RewriteBase is needed
Rules work inconsistently or loop Earlier matches, conditions, or missing terminating flags Trace the rules in order and add an appropriate [L] or [END]
A redirect still goes to the old destination Client or intermediary cache, usually from a previous 301 Test with a temporary 302 in a private window

How Apache processes a .htaccess rewrite

A .htaccess file is a per-directory configuration file. Apache only consults it when the server’s configuration allows overrides for that directory. Once the file is accepted, mod_rewrite evaluates rules sequentially. For each rule, the pattern must match and all preceding RewriteCond directives attached to it must pass. Only then is the substitution applied. Flags such as [L] and [END] can stop further rewriting.

That context differs from a server or virtual-host configuration. In a root-level .htaccess, Apache removes the directory prefix before matching. A request for /old-path is therefore tested as old-path, not /old-path. This single difference explains many apparently valid rules that never fire.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

1. Prove that Apache is reading the file

Check the filename and location

The file must be named exactly .htaccess, including the leading dot and lowercase spelling. Put it in the directory covered by the request: normally the active document root, or the relevant application subdirectory. If several directories contain files with that name, Apache may process more than one file as it walks the path, so first identify which directory actually serves the URL.

Inspect the matching Directory policy

Apache 2.4’s core default is AllowOverride None. With that setting, the file is completely ignored. For rewrite directives, the applicable directory must permit at least FileInfo overrides, or use AllowOverride All. A server administrator can also use an AllowOverrideList policy to allow selected directives. The setting must be in the <Directory> block that matches the filesystem directory, not merely in an unrelated virtual host block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<Directory "/var/www/example/public">
    AllowOverride FileInfo
</Directory>

After changing the main Apache configuration, reload or restart Apache according to the host’s operating procedure. Shared hosting often does not expose this block; in that case, no edit inside .htaccess can override a server policy that disallows it.

Use a harmless read test

Do not begin by changing a complex rule. Confirm the file is in the served tree and that a deliberately invalid directive produces a clear “unknown directive” error, then remove the test immediately. If the invalid line produces no error and no behavior change, that is evidence Apache never read the file. Perform this only where you can safely inspect the error log; on managed systems, ask the provider to confirm the effective directory policy instead.

2. Confirm mod_rewrite and the rewrite engine

Look for module availability

The directives RewriteRule, RewriteCond, and RewriteEngine belong to mod_rewrite. If Apache reports an unknown directive, the module is not loaded or the directive is not permitted in that context. Loading a module is a server-level task; it cannot be repaired by adding more rules to .htaccess.

Enable the engine explicitly

At the top of the relevant file, use:

RewriteEngine On

Without this line, the module may be available while rule processing remains disabled for that directory. Keep one clear engine declaration near the start of each file and then test a minimal rule before restoring conditions and exceptions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

3. Fix per-directory pattern syntax

Remove the leading slash

In .htaccess context, match the path after Apache has removed the directory prefix. For a file in the document root:

RewriteEngine On
RewriteRule ^old-path/?$ new.html [L]

This matches /old-path and an optional trailing slash. The equivalent pattern with a leading slash, ^/old-path, does not match in this context.

Account for a subdirectory file

If the file is in /var/www/example/public/blog/.htaccess, the rule sees the portion below blog. A request for /blog/archive/post is tested as archive/post, so the pattern should be:

RewriteRule ^archive/post/?$ article.html [L]

Do not copy a rule written for a virtual-host configuration into .htaccess unchanged. The matching string and the substitution’s relative meaning can both change.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Test the smallest possible pattern

Temporarily replace a complicated expression with a literal path and a known target. Once that works, reintroduce optional slashes, capture groups, exclusions, and conditions one at a time. This distinguishes a context error from a regular-expression error.

4. Resolve AH00670 and symbolic-link restrictions

Per-directory rewriting requires Apache to permit either Options FollowSymLinks or Options SymLinksIfOwnerMatch. If neither option is enabled in the permitted directory context, Apache can reject rewrite processing and log AH00670.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
<Directory "/var/www/example/public">
    AllowOverride FileInfo
    Options FollowSymLinks
</Directory>

Some hosts disallow changing Options from .htaccess; others permit a narrowly scoped setting such as:

Options SymLinksIfOwnerMatch

Use the option already approved by the administrator, and do not loosen unrelated directory permissions to make a rewrite work. If you cannot alter the directory policy, the practical fix is a server administrator or a hosting plan that supports Apache 2.4, mod_rewrite, and customer overrides.

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.

5. Decide whether RewriteBase is actually required

RewriteBase supplies the URL base for relative substitutions in per-directory rewriting. It matters when the URL path and filesystem path do not line up, such as an application served through an Alias or deployed below a URL subdirectory. It does not change how a pattern matches, and it has no effect on an absolute substitution.

Relative substitution in a subdirectory

Suppose an application is exposed at /myapp/ and a rule uses a relative target:

RewriteBase /myapp/
RewriteRule ^login/?$ index.php [L]

The base tells Apache how to turn the relative index.php substitution into the public URL for that deployment. Confirm the actual mount point before choosing the value; a base copied from another installation can create an incorrect path.

When not to add it

An absolute URL-path substitution such as /new-location, or a complete URL such as https://example.test/new-location, already states its destination. Adding RewriteBase in that case cannot correct a leading-slash pattern, a failed condition, or a wrong directory policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

6. Audit conditions, order, and terminating flags

Read each RewriteCond as a gate

Every RewriteCond immediately before a rule must evaluate true for that rule to run. Check the variable being tested, its spelling, and the exact regular expression or comparison. A correct RewriteRule still appears broken when a host, request URI, query string, or file-test condition excludes the request.

RewriteCond %{REQUEST_URI} ^/old-path/?$
RewriteRule ^old-path/?$ /new-path [R=302,L]

In this example, the condition includes the URL slash because REQUEST_URI is a request variable, while the rule pattern omits it because the rule is in .htaccess. Mixing those two contexts is a common source of confusion.

Follow the rules from top to bottom

Apache evaluates rules sequentially. A broad earlier rule can consume a request before a specific rule is reached. Conversely, a rule without an appropriate terminating flag can allow a later rule to rewrite the result again. Put narrow exceptions before broad catch-all rules, and add [L] when the current per-directory pass should stop after a match.

Choose L versus END deliberately

[L] stops the current rewrite pass; Apache may perform another pass after an internal rewrite. [END] is stronger and terminates per-directory rewriting for the request. Use it when an internal rewrite would otherwise re-enter the same rules, but verify compatibility with the Apache version and the rest of the application. A flag cannot repair a pattern that never matched.

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

Detect loops

Redirect loops and repeated internal rewrites usually occur when the target also satisfies the original rule. Add an explicit exclusion for the destination, test the request URI and filename conditions, and inspect the trace log before adding more flags. Do not mask a loop by stacking redirects; make the source and destination mutually distinguishable.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

7. Turn on rewrite tracing briefly

When the configuration and syntax look correct, make Apache’s decision visible. In server configuration, temporarily set:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
LogLevel alert rewrite:trace3

Request the failing URL once, then read the Apache error log. Trace output shows which pattern was tested, whether conditions passed, and what substitution was selected. It can also reveal a rule being applied in a different directory than expected.

Trace logging is verbose and can expose request details, so use it only for the short reproduction window and then remove it or return the log level to its normal value. If you lack error-log access, ask the administrator for the relevant trace lines; guessing from browser output alone hides the distinction between “file ignored,” “pattern failed,” and “target generated a 404.”

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

8. Debug redirects with 302 before using 301

A permanent redirect is commonly cached by browsers and intermediary systems. If you previously sent visitors to the wrong destination with a 301, correcting the rule may appear ineffective because the client reuses the old response.

RewriteEngine On
RewriteRule ^old-path/?$ /new-path [R=302,L]

Test that rule in a private window or with a client whose redirect cache you can clear. Once the destination is confirmed, change the response to R=301 if the move is genuinely permanent. Keep the temporary status while diagnosing; it makes each change observable and avoids creating another sticky result.

Working rule patterns for common deployments

Document-root redirect

RewriteEngine On
RewriteRule ^old-path/?$ /new-path [R=302,L]

The pattern is slashless because this is a document-root .htaccess. The substitution begins with a slash because it is an absolute URL-path destination.

Internal rewrite to an application entry point

RewriteEngine On
RewriteRule ^products/([^/]+)/?$ index.php?product=$1 [END]

The captured product name is passed to the application without exposing index.php in the browser’s address bar. Add conditions only after this basic match works, and ensure the target does not trigger the same pattern indefinitely.

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

Alias or mounted application

RewriteEngine On
RewriteBase /myapp/
RewriteRule ^dashboard/?$ index.php [L]

This form is appropriate only when the application is publicly mounted below /myapp/ and the relative substitution needs that URL base. If the substitution is changed to an absolute URL path, reassess whether the base is still necessary.

Failure-specific recovery paths

Silent no-op

  • Confirm the request reaches the directory containing the file.
  • Check the matching <Directory> block for AllowOverride FileInfo, AllowOverride All, or an appropriate AllowOverrideList.
  • Verify mod_rewrite is loaded and RewriteEngine On is present.
  • Use a minimal literal rule before restoring complex conditions.

HTTP 404 after a rewrite

  • Determine whether the substitution is intended to be a filesystem path, a URL path, or an external URL.
  • For a relative target, check the directory context and possible RewriteBase requirement.
  • For an absolute target, confirm the target exists and do not expect RewriteBase to alter it.
  • Use trace logging to see the exact substitution Apache generated.

HTTP 500 or AH00670

  • Read the error log rather than changing the regular expression first.
  • Enable FollowSymLinks or SymLinksIfOwnerMatch where policy permits.
  • Check for unknown directives that indicate a missing module or disallowed override.

Redirect loop

  • Compare the incoming URL with the post-rewrite URL.
  • Exclude the destination from the source pattern or condition.
  • Use [END] where repeated per-directory passes are the cause.
  • Trace one request and remove verbose logging immediately afterward.

Old redirect persists

  • Replace 301 with 302 while testing.
  • Use a private browser window or clear the relevant redirect cache.
  • Retest after each change and only restore 301 after the destination is final.

A safe troubleshooting order

  1. Verify the exact filename, its directory, and the active document root.
  2. Confirm the matching <Directory> policy permits FileInfo overrides; remember that AllowOverride None ignores the file.
  3. Confirm mod_rewrite is available and add RewriteEngine On.
  4. Reduce the rule to a slashless, literal per-directory pattern.
  5. Resolve FollowSymLinks or SymLinksIfOwnerMatch requirements.
  6. Check whether a relative substitution crosses a subdirectory or Alias boundary and needs RewriteBase.
  7. Evaluate conditions and rule order, then choose [L] or [END] to control subsequent passes.
  8. Enable LogLevel alert rewrite:trace3 for one reproduction and inspect the error log.
  9. Use a 302 and a private window for redirect tests; switch to 301 only after verification.

Server-version and hosting limits

The behavior described here follows Apache HTTP Server 2.4 and current project documentation. Defaults and the controls exposed by a hosting provider can differ by version and policy, so verify the active server version before applying a configuration copied from another environment.

If you cannot edit the relevant <Directory> block, load modules, enable the required options, or read the error log, the limitation is administrative rather than a flaw in your rule. Ask for confirmation that the server supports Apache 2.4, mod_rewrite, customer .htaccess overrides, and the needed symbolic-link option. A managed Apache host with those capabilities is the appropriate category to investigate; no amount of regex editing can bypass a server that refuses to read the file.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.