Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Fix the 500 Error After Adding mod_expires Rules to .htaccess

A 500 after editing .htaccess means Apache rejected the configuration. Follow a log-first process to verify mod_expires, AllowOverride policy, syntax, MIME types, and response headers.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 500 response that appears immediately after you edit .htaccess usually means Apache rejected the file while parsing it. The fastest fix is not to guess at cache durations: read the Apache error log, confirm that mod_expires is available, verify that the directory permits the required overrides, and then rebuild the rules from a small known-good block.

The configuration below uses Apache’s documented directives and readable interval syntax. Once it loads successfully, add additional MIME types one at a time and verify the response headers with curl -I or your browser’s developer tools.

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 the 500 error means in this situation

HTTP status 500 is a server-side failure. When it starts directly after saving an .htaccess edit, Apache has commonly encountered a configuration problem before it can serve the request. The error can be a misspelled or unsupported directive, a directive used in a context the server does not permit, a missing module, or invalid syntax in the file.

The public error page is intentionally vague. Apache’s error log is the authoritative starting point because it normally records the affected .htaccess path, the line number, and a message describing the failure. Typical messages include “Invalid command,” “directive not allowed here,” and a syntax error. Do not repeatedly change cache values until you have read that entry; the wording determines which branch of the repair applies.

#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.

Read the error log before changing the rules

  1. Reproduce the problem once. Request the affected URL so the current failure is written to the log.
  2. Open the Apache error log used by your host. On managed hosting this may be exposed in a control panel; on a self-managed server it is the virtual host or Apache error log configured for that site.
  3. Find the newest entry for the request. Record the full .htaccess path, line number, and message. A line reference is more useful than the browser’s generic 500 page.
  4. Classify the message. An invalid command points toward a missing module or unsupported directive. “Not allowed here” points toward override policy or directive context. A syntax error points toward spelling, quoting, or interval-format problems.

Keep that entry while testing. If a later edit produces a different line number or message, treat it as new evidence rather than assuming the original problem remains.

Confirm that mod_expires is available

ExpiresActive, ExpiresDefault, and ExpiresByType are provided by Apache’s mod_expires module. Some Apache builds do not compile the module in by default, so a perfectly spelled rule can still fail when the provider is absent.

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

Use the server’s module listing

Check the enabled-module listing supplied by your host or server administration interface and look for mod_expires. If your hosting control panel has an Apache-module selector, use that interface to confirm availability. The exact screen differs by host, so the important result is whether the module is loaded for the Apache instance serving this site.

Interpret an “Invalid command ExpiresActive” message

An error that names ExpiresActive as an invalid command strongly suggests that Apache does not know the directive. Verify the module first. If the module is not available to your account, an .htaccess edit cannot enable it; ask the host to load it or use the host’s supported caching configuration instead.

If the module listing shows mod_expires but the log still reports an invalid command, check that the request is reaching the same Apache installation and virtual host whose modules you inspected. A control panel can display settings for a different service than the one handling the domain.

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

Check AllowOverride and .htaccess policy

Having mod_expires loaded is necessary but not sufficient. Apache must also permit the relevant directives in .htaccess. The documented requirement is that both AllowOverride Options and AllowOverride FileInfo be in effect for these directives to have an effect.

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

When overrides are permitted

If the directory’s override policy includes the required classes, Apache can process the expiration directives in the file. A “directive not allowed here” message usually means the policy does not include the class needed by the directive, or that the file is being read in a context where overrides are disabled.

When overrides are disabled

A host may configure a directory with overrides disabled. Depending on the server configuration, Apache may reject the request when it encounters the file or may ignore directives that are not permitted. The error log tells you which behavior applies. You cannot solve a server-level override restriction by rearranging lines in .htaccess; the directory or virtual-host configuration must be changed by someone with server access.

Ask the host or administrator whether Options and FileInfo overrides are enabled for the document root that contains this file. Include the exact log message and path so they can check the correct directory rather than a similarly named site.

Replace the file contents with a minimal known-good block

After the module and override checks, reduce the configuration to the smallest useful set. Remove or comment out the new expiration lines temporarily, then use this block exactly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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)
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "access plus 1 hour"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"

This tests all three documented directives while keeping the example short. The readable access plus form is quoted because the interval is a multiword expression. The sample gives HTML a one-hour expiration and CSS and JavaScript a one-month expiration; those values are examples of valid syntax, not a universal caching policy.

  1. Save the minimal block in the site’s actual .htaccess file.
  2. Request the site again.
  3. If the 500 remains, return to the newest error-log entry. It may identify a module or override problem unrelated to the interval values.
  4. If the site loads, add one additional directive at a time, testing after each addition.

Adding rules incrementally isolates the first line that changes a working configuration into a failing one. It also prevents a long copied block from hiding the actual cause.

Validate each ExpiresByType line

ExpiresByType expects a MIME type followed by an interval expression. The MIME value must describe the response’s content type, not merely its filename extension. The minimal example uses text/html, text/css, and application/javascript.

Correct the MIME type

If a rule targets a type that the response does not use, Apache may load the file successfully but no expiration header will be selected for that response. Check the response’s actual Content-Type while testing. Keep the type in the standard type/subtype form, without a filename suffix or a leading dot.

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

Keep the interval expression syntactically intact

Use Apache’s readable interval syntax, such as "access plus 1 hour" or "access plus 1 month", with the quotation marks included. A missing quote, an extra character, or a copied expression that is not accepted by the server can trigger a syntax error. When troubleshooting, change one part of one line at a time instead of replacing all intervals at once.

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

Distinguish a syntax failure from a matching failure

A syntax failure prevents Apache from accepting the configuration and commonly produces the immediate 500. A MIME mismatch is different: Apache can accept the configuration, but the response may not receive an Expires header because no rule matches its type. Use the error log for the former and response inspection for the latter.

Understand access-based and modification-based expiration

Apache can calculate expiration from the client’s access time or from the file’s modification time. In configuration terminology these are represented by A or access and M or modification.

Access-time expiration

An expression such as "access plus 1 month" bases the expiry on when the client receives the response. It is useful when the policy is expressed as a period from each access, independent of when the file was last changed.

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

Modification-time expiration

A modification-based expression calculates from the resource’s file modification time. That calculation is unavailable for responses that do not have a file modification time, so it is not suitable for every kind of response. If a response is generated dynamically or otherwise lacks that timestamp, use an access-based policy or configure caching through the system that creates the response.

Changing from access-based to modification-based timing does not fix a parser error. Choose the basis only after the file loads and you are deciding how the resulting expiration should behave.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reload and verify the headers

Once the minimal block loads without a 500, reload Apache through the normal mechanism provided by your host or server administrator. Shared hosting may apply changes automatically when the file is saved; managed or self-managed servers may require an administrator-controlled reload.

Inspect a response with curl

Request the resource headers without downloading the body:

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.
curl -I https://example.com/path/to/resource

Replace the example URL with a resource that should match one of your rules. You can also open browser developer tools, select the request in the Network panel, and inspect the response headers.

What a successful result looks like

A matching rule may produce an Expires header along with cache-related headers. Check the response’s Content-Type to confirm that the intended ExpiresByType rule applies. Test an HTML page separately from a CSS or JavaScript file because each type can have a different interval.

ExpiresActive On by itself does not guarantee an Expires header. Apache documents that a header is generated only when the request meets a configured expiration criterion. If the site loads but the header is absent, first verify MIME matching and whether a default or type-specific rule applies; do not treat the absence alone as proof that the module failed to load.

Use the log and response together to choose the fix

Observed result What it indicates Next action
Log says “Invalid command ExpiresActive” Apache does not recognize the directive, commonly because mod_expires is unavailable to that server. Check the module listing or hosting control panel and ask the host to enable the module if necessary.
Log says the directive is not allowed here The directory’s .htaccess override policy does not permit the required directive class. Have the administrator enable both AllowOverride Options and AllowOverride FileInfo for the relevant directory, or move the rule to an allowed server configuration.
Log identifies a syntax error on one line The directive spelling, quoting, MIME token, or interval expression is malformed or unsupported in that context. Restore the minimal block, then reintroduce the failing line with the documented syntax.
Configuration loads, but no Expires header appears No expiration criterion matched the response, or the response lacks the required file metadata for the selected basis. Inspect Content-Type, add the appropriate ExpiresByType rule, and consider access-based timing for responses without a modification time.
One MIME type works and another does not The second response is using a different MIME type than the rule targets. Compare the response’s actual type with the ExpiresByType token and correct the rule.

Roll back safely when the site is still returning 500

  1. Restore the last .htaccess version that served requests successfully, or remove only the newly added expiration block.
  2. Request the site once and confirm that the 500 is gone.
  3. Read the latest error-log entry to ensure no separate syntax error remains elsewhere in the file.
  4. Check mod_expires availability and the two required override classes before trying again.
  5. Reapply only the minimal block, test, and then add individual rules.

Do not leave a partially edited file in place while asking for support. Give the administrator the exact file path, failing line, and log message; those details allow a module or policy issue to be fixed at the server level instead of guessed at in the browser.

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.

Limits of mod_expires

mod_expires controls expiration metadata. It does not make a resource immutable, guarantee that every client or intermediary will cache it, or force an Expires header onto every response. The module supplies timing information when an active rule matches and the response has the metadata required by the selected calculation method.

That distinction explains two otherwise confusing outcomes: a malformed directive can cause an immediate 500 before any response is generated, while a valid configuration can load normally and still produce no Expires header for a response that matches no criterion. Treat those as separate problems and use the log for configuration failures and header inspection for cache-policy verification.

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.

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.