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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

When Apache appears to ignore a .htaccess RewriteRule, start with server configuration, not the regular expression. Apache 2.4 defaults to AllowOverride None, which prevents the file from being read; in per-directory context Apache also removes the directory prefix, so a pattern beginning with / will not match. After those checks, verify mod_rewrite, symlink options, substitution bases, rule order, trace logs, and redirect caching.

Use this diagnostic order

Work from the outside in. A rule cannot match if Apache is not reading the file, the rewrite module is unavailable, or the request is rejected by directory security settings. Only after those prerequisites pass should you tune patterns, conditions, and flags.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Confirm the file is named .htaccess, is below the active DocumentRoot (or the intended subdirectory), and is covered by the correct <Directory> configuration.
  2. Confirm mod_rewrite is loaded and the file contains RewriteEngine On.
  3. Remove a leading slash from RewriteRule patterns in .htaccess.
  4. Permit FollowSymLinks or SymLinksIfOwnerMatch where per-directory rewriting runs.
  5. Use RewriteBase only when a relative substitution needs a URL base different from its filesystem location.
  6. Check every RewriteCond, the order of rules, and terminating flags such as [L] and [END].
  7. Enable temporary rewrite trace logging, then inspect the error log.
  8. Test redirects with a temporary 302 so a cached 301 does not hide the fix.

The sections below explain each step and show working patterns for document-root, subdirectory, and alias deployments.

1. Make sure Apache is reading the file

The most common silent failure is an override policy that excludes rewrite directives. Apache’s current core documentation states that the default is AllowOverride None. With that setting, the server ignores .htaccess files in the directory tree. The Apache per-directory rewrite documentation puts the requirement plainly: “Without at least AllowOverride FileInfo (or AllowOverride All), any mod_rewrite directives in .htaccess files are silently ignored.”

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Check the filename and location

  • The name must be exactly .htaccess, including the leading dot and lowercase spelling. A file such as htaccess, .htaccess.txt, or .HTACCESS is a different file.
  • Place it in the active DocumentRoot or in a descendant directory. A file in another virtual host’s tree has no effect on this request.
  • Check the virtual host that answered the request. A DNS change, alternate port, or HTTPS virtual host can send you to a different document root than the one you edited.
  • Ensure the Apache process can read the file and traverse its parent directories. A permissions problem normally appears in the error log rather than as a clean no-op.

Check the matching Directory block

The relevant server or virtual-host configuration must allow at least the FileInfo override class for rewrite directives. A typical configuration is:

<Directory "/var/www/example/public">
    AllowOverride FileInfo
</Directory>

AllowOverride All also permits it, but grants many more classes of directives than a rewrite-only site needs. On installations using AllowOverrideList, the administrator must allow the individual directives used by the file, such as RewriteEngine, RewriteRule, and RewriteCond. If an enclosing or more-specific <Directory> block still sets AllowOverride None, the file remains ineffective.

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.

What you can and cannot change

Only a server administrator (or a hosting control panel that exposes the setting) can change the <Directory> policy, load modules, or enable the required options. If you receive a 500 error after adding a directive, read the error log; if the file simply does nothing, first suspect that overrides are disabled. On managed Apache hosting, ask specifically whether Apache 2.4, mod_rewrite, and customer .htaccess overrides are enabled.

2. Verify mod_rewrite and the rewrite engine

A valid pattern cannot run without the module. On Debian- and Ubuntu-style systems, an administrator can enable it with:

sudo a2enmod rewrite
sudo systemctl reload apache2

Other distributions use their own module configuration, and shared hosts may not expose it. The dependable checks are the server’s loaded-module list and the Apache error log.

Recognize module and syntax failures

  • An error such as “Invalid command ‘RewriteEngine’” or “Invalid command ‘RewriteRule’” means the rewrite module is not loaded, or the directive is not permitted in that context.
  • A 500 response immediately after editing the file usually indicates a configuration or directive error. The error log identifies the line.
  • A normal page with no redirect or rewrite can mean the engine is off, the file is ignored, a condition failed, or a pattern did not match.

Put the engine directive before rules:

RewriteEngine On

Do not place it inside a comment or conditional block that is never reached. If you can edit the main configuration, run Apache’s configuration test before reloading; never reload a server that reports a syntax error.

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

3. Remove the leading slash from .htaccess patterns

In server configuration context, a RewriteRule pattern may be matched against a path that starts with /. In .htaccess (per-directory) context, Apache strips the current directory prefix and the leading separator before it evaluates the pattern. A request for /old-path in the document root is therefore presented to the rule as old-path, not /old-path.

Document-root example

This rule matches exactly /old-path, with an optional trailing slash:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
RewriteEngine On
RewriteRule ^old-path/?$ new.html [L]

This commonly attempted version does not match in .htaccess:

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

Subdirectory example

If the file is /var/www/example/public/blog/.htaccess, a request for /blog/archive is matched as archive inside that file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
RewriteEngine On
RewriteRule ^archive/?$ archive.html [L]

Do not repeat blog/ in the pattern unless the rule is located in the document-root file. The same stripping explains why a rule copied from a virtual-host configuration can fail after being moved into a subdirectory’s .htaccess.

Match only what you intend

Use anchors when a rule should match the whole relative path. ^old-path/?$ does not also match old-path-extra. Capture groups remain available as $1, $2, and so on in the substitution:

RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [L,QSA]

That pattern sees products/42 in a document-root .htaccess. Query-string behavior should be chosen deliberately; QSA appends the original query string instead of discarding it when the substitution supplies a new one.

4. Satisfy per-directory symlink requirements

Apache requires a permitted symlink option for per-directory rewriting. Enable either Options FollowSymLinks or Options SymLinksIfOwnerMatch in the applicable directory context:

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

If policy or ownership rules prohibit unrestricted following, use SymLinksIfOwnerMatch where appropriate. The exact option must be allowed by the server’s override policy; adding it to a file that cannot use Options will itself fail.

Interpret AH00670

The Apache error-log message AH00670 indicates that the per-directory rewrite engine refused to proceed because neither required symlink option was enabled. This is not a regular-expression problem. Correct the directory configuration, reload Apache if you changed server-level settings, and repeat the request.

Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Do not blindly add Options +FollowSymLinks to every site. Follow the host’s security policy and use the least permissive setting that satisfies the deployment. If you cannot change it, the administrator must make the change; no RewriteRule flag can bypass the requirement.

5. Decide whether RewriteBase is needed

RewriteBase supplies the URL-path base used to construct a URL from a relative substitution. It matters when the URL path and filesystem path do not line up, notably with an Alias or some applications deployed below a subdirectory. It does not alter pattern matching and does not affect an absolute substitution.

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.

Relative substitution under a subdirectory

Suppose an application is exposed at /myapp/, and its .htaccess uses a relative target:

RewriteEngine On
RewriteBase /myapp/
RewriteRule ^old$ new.html [L]

The relative target is resolved under the declared URL base. The correct base depends on the public URL, not merely the operating-system directory name.

When it is unnecessary

Leave RewriteBase out when the substitution is already an absolute URL-path or full URL:

RewriteRule ^old$ /new.html [R=302,L]
RewriteRule ^old$ https://www.example.test/new.html [R=302,L]

Adding a base to “make rewriting work” cannot repair a disabled module, a leading-slash pattern, a failed condition, or a wrong rule order. First establish that the rule is reached; then use a base only if relative URL construction is the remaining issue.

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

6. Check conditions, order, and terminating flags

Apache evaluates rules sequentially. A RewriteRule pattern and all RewriteCond directives immediately preceding it must pass before Apache applies the substitution. A prior rule can rewrite the request first, and a terminating flag can prevent later rules from running.

Audit each condition

For every condition, write down the variable being tested, the value it has for the failing request, and the regular expression or comparison applied to it. Common mistakes include testing THE_REQUEST when the desired value is in REQUEST_URI, using a host name that differs between HTTP and HTTPS, and forgetting that a condition applies only to the next RewriteRule.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

Here both “not a file” and “not a directory” tests must pass. A real file or directory bypasses the front-controller rule by design.

Put specific rules before broad fallbacks

A catch-all rule such as RewriteRule ^ index.php [L] belongs after exceptions for assets, health checks, or special paths. Otherwise the broad match handles the request first. Conversely, a redirect that should happen before an internal rewrite must appear above the internal rewrite.

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

Understand L versus END

[L] stops the current per-directory rewrite pass. Because Apache may run another pass after an internal rewrite, a later pass can still evaluate rules. Apache 2.4’s [END] flag terminates per-directory rewriting for the current request, which can prevent a loop when an internal target would otherwise re-enter the same rules. Use it only when that stronger termination is intended.

Detect loops

A redirect loop or repeated internal rewrite often means the target also satisfies the source pattern. Exclude the destination, test the original request, or use a condition that distinguishes an external request from an internally rewritten one. The error log and browser’s network panel will show repeated 3xx responses or a 500 “too many internal redirects” failure.

7. Turn on trace logging briefly

When the configuration looks correct but behavior is still unclear, increase rewrite logging temporarily:

LogLevel alert rewrite:trace3

Place this in a server- or virtual-host configuration where your Apache version permits it, then reload Apache. Reproduce one request and inspect the error log. Trace output shows the path Apache tests, condition results, selected rule, and substitution, making it possible to distinguish “file ignored,” “pattern did not match,” “condition failed,” and “rule matched but was superseded.”

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

Use trace safely

  • Trace logging can be verbose and may expose request paths or query strings; enable it only for the shortest useful interval.
  • Reproduce a single request rather than refreshing a busy production page repeatedly.
  • Remove the trace setting or return to the normal log level immediately after collecting evidence.
  • Read the correct virtual host’s error log; a distribution may separate logs by site.

If you have no error-log access, ask the administrator to run the reproduction with tracing. Without logs, a silent no-op cannot reliably be separated from a condition failure or a request reaching another virtual host.

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

8. Rule out cached redirects

Browsers and intermediaries can cache a permanent 301. After you change its destination, your browser may continue sending you to the old location even though Apache now emits the new one.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Debug with a temporary redirect

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

Use a private window or a client that does not reuse the browser’s redirect cache, and inspect the response’s Location header. Once the destination is verified, change the status to 301 if the move is genuinely permanent. A cached 301 already stored by visitors cannot be withdrawn by editing the rule; testing with a new path or a clean client is often necessary.

A redirect that appears to “keep using the old destination” is therefore not automatically an Apache failure. Confirm the actual response at the server before changing more rules.

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

Symptom-to-fix reference

Symptom Most likely cause First check
Nothing changes; no error AllowOverride None, wrong file/location, engine off, or a non-matching pattern Matching <Directory> block, filename, RewriteEngine On, then trace logging
Rule works in virtual-host config but not in .htaccess Leading slash or different per-directory path Remove / from the pattern and account for the directory prefix Apache strips
Immediate 500 response Directive/module error, forbidden option, or rewrite loop Read the error log; look for unknown directives, AH00670, and redirect-loop messages
404 after an apparently successful rewrite Wrong relative substitution base or target path Check whether the target is relative, whether an alias/subdirectory needs RewriteBase, and whether the target exists
Redirect repeats Source and destination both match, or multiple rules redirect the same request Trace rule order and add an appropriate exclusion or terminating flag
Old redirect persists Cached 301 in the browser or an intermediary Test with 302 in a private client and inspect the live Location header

Complete patterns you can adapt

Document-root old URL to a new URL

RewriteEngine On

# /old-path and /old-path/ redirect temporarily while testing
RewriteRule ^old-path/?$ /new-path [R=302,L]

After testing from a clean client, replace 302 with 301 only if the redirect is permanent.

Front controller that preserves existing files

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [END]

This is appropriate only when the application is intended to handle every non-file, non-directory request. If the host does not support END, use [L] and ensure the application target cannot trigger a loop.

Application mounted at a URL prefix

RewriteEngine On
RewriteBase /myapp/
RewriteRule ^old$ new.php [L]

Use this form when the relative target must resolve under /myapp/. If the target is written as /myapp/new.php or as a full https:// URL, the explicit base is not needed for that rule.

What to record before changing a rule

  • Apache version and whether the request is served by the expected virtual host.
  • Absolute filesystem path of the active document root and the .htaccess file.
  • The exact request URL, method, host, scheme, and query string.
  • The current <Directory> settings for overrides and options.
  • Whether the substitution is relative, URL-path absolute, or a full URL.
  • The response status, Location header, and relevant error-log lines.

Apache 2.4 and current trunk documentation support the directives and flags described here, but providers can change defaults and restrict what customers may override. Verify the active server version and policy before applying a setting copied from another installation.

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

When the correct fix is outside .htaccess

If AllowOverride is disabled, AllowOverrideList excludes the rewrite directives, mod_rewrite is not loaded, or the required Options setting is prohibited, no regex edit in .htaccess can solve the problem. Move the rule into the virtual-host/server configuration if you administer Apache, or ask the host to enable the needed capability. A provider that supports Apache 2.4, mod_rewrite, and customer overrides is a prerequisite for an .htaccess-based application.

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.