Free tools Windows power users keep installed
One-click scans. No signup required.
On Apache, the usual .htaccess rule is a mod_rewrite condition that checks HTTP_USER_AGENT and returns a 403 response:
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (BadBot|AnotherBot) [NC]
RewriteRule ^ - [F,L]
Replace the names with a distinctive fragment from your access logs. This blocks clients that identify themselves with those strings, but it is not a security boundary: a client can change its User-Agent header trivially.
As an Amazon Associate I earn from qualifying purchases.
What the .htaccess rule does
Every HTTP request normally includes a User-Agent header. Apache exposes that header to rewrite rules as %{HTTP_USER_AGENT}. The condition tests the header with a regular expression; when it matches, the rule refuses the request before your application handles it.
The example uses two alternatives, BadBot and AnotherBot. The vertical bar (|) means “or”, so either name triggers the condition. Add more alternatives only when you have clear evidence that each one identifies the unwanted client.
#1 Best Overall
- 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.
[NC]makes the comparison case-insensitive, so capitalization changes do not evade this particular match.- The hyphen in
RewriteRule ^ -is a no-op substitution. Apache keeps the requested URL instead of rewriting it to another path. [F]returns a forbidden response, normally HTTP 403.[L]stops processing later rewrite rules in the current rewrite round.
This is a filter for cooperative or low-effort unwanted clients. It does not prove who made a request, validate a crawler’s identity, or prevent a determined client from sending a different header.
Check the server before editing
Whether this works depends on the Apache installation and the directory in which the file is used. Confirm these points first:
- Apache is serving the request and the relevant directory permits
.htaccessoverrides through itsAllowOverridepolicy. mod_rewriteis loaded if you plan to useRewriteCondandRewriteRule.- You know which
.htaccessfile controls the URL: the document-root file applies broadly, while a file in a subdirectory has a narrower scope. - You have a copy of the existing file. Preserve front-controller rules used by a CMS or framework; deleting them can turn working routes into 404 errors.
- You can read the Apache error log and make a test request with a controlled User-Agent.
If you do not administer the main Apache configuration, .htaccess is often the available configuration layer. A host that disables overrides or does not load the required directives cannot use these snippets unchanged; ask the administrator which authorization and rewrite directives are permitted.
Hosting requirements and practical constraints
The title alone cannot establish whether a particular hosting plan supports this configuration. Apache must be allowed to read per-directory files, and the administrator’s AllowOverride settings determine which directive groups are accepted. Some providers permit rewrite rules but restrict authorization directives; others disable .htaccess entirely in favor of a central virtual-host configuration.
When comparing hosting options, verify that Apache compatibility, per-directory overrides, and the required module are included. The relevant cost is therefore the capability of the plan rather than a special fee for this rule; prices and availability vary by provider, so confirm the plan’s documentation or ask support before migrating a site. If you control the server configuration, a central configuration is usually preferable for performance and governance, but this article focuses on the per-directory method available when that access is not available.
Install a site-wide User-Agent block
1. Back up and open the correct file
Copy the document-root .htaccess before changing it. Open the file in the directory whose requests should be filtered. In a document-root file, the rule can cover every path handled by that directory.
2. Enable rewriting and add the condition
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (BadBot|AnotherBot) [NC]
RewriteRule ^ - [F,L]
RewriteEngine On enables rewrite processing for that context. The condition reads the complete User-Agent value and applies the regular expression. The rule pattern is ^, which matches every path presented to a document-root per-directory rule.
3. Put the block before broad rewrites
Place the deny rule before catch-all rules that send requests to an index file or another application route. If a preceding rule rewrites the request, the unwanted client may reach the application before the block is evaluated, or the later rule may run in a different rewrite round. Keep the site’s existing ordering in mind rather than moving unrelated rules blindly.
Rank #2
- 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
Do not duplicate RewriteEngine On unnecessarily, and do not remove existing conditions simply to make room for the block. Keep comments beside a deny list so the reason for each entry is clear. A short, documented list is easier to audit than a single opaque expression containing every word that has appeared in a log.
4. Save, then test both matching and normal requests
Use a command-line client or browser tool that lets you set the header. With a shell variable holding the site’s base address, for example:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemscurl -I -A 'BadBot' "$SITE_URL/"
curl -I -A 'OrdinaryBrowser' "$SITE_URL/"
The first request should receive a forbidden response when the expression matches; the second should continue through the site’s normal routing. Inspect the response headers and Apache’s error log while testing. The commands are a validation procedure, not a substitute for checking your production logs.
Test a URL that is actually served by the directory containing the file, and test both an ordinary page and a static asset if your goal is site-wide coverage. A successful 403 confirms the request was denied, but it does not prove that every proxy, cache, or alternate hostname applies the same file. Test through the public hostname and any separate application entry points that matter to your deployment.
Limit the block to one directory
A rule in a document-root file can target a subtree by changing the rule pattern:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (BadBot|AnotherBot) [NC]
RewriteRule ^private/ - [F,L]
Here, only paths beginning with private/ in that per-directory context are denied. Adjust the path to the directory you actually want to protect.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Per-directory matching is easy to misread. Before Apache evaluates a RewriteRule in an .htaccess file, it removes that file’s directory prefix from the URL. If the file itself is inside a private directory, a request for /private/report.pdf is evaluated there as report.pdf, not private/report.pdf. In that inner file, use a pattern such as ^ or ^report.pdf$ rather than repeating the parent directory name.
The condition still examines the User-Agent header regardless of the URL pattern. You can therefore use one expression for the client and choose the scope independently by selecting the appropriate .htaccess location and rule pattern.
Rank #3
- 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)
Choose the narrowest location that meets the goal. A rule in an inner directory does not automatically cover sibling directories, and a rule in the root can affect administrative paths, APIs, images, feeds, and health checks. Scope is a functional decision, not merely a syntax detail.
Choose a precise User-Agent expression
Match a distinctive fragment
Use text that is unlikely to occur in legitimate clients. A generic word such as bot can match far more traffic than intended. Start with the exact spelling and punctuation seen in access logs, then decide whether case-insensitive matching is appropriate.
Recommended Free Tools
Anchor an intended prefix
If the unwanted client identifies itself at the beginning of the header, anchor the expression:
RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot [NC]
The leading caret means the match must start at the beginning of the User-Agent value. Apache’s authorization example uses this prefix style. It reduces accidental matches where the same text appears later in an unrelated product name.
Bound a more complex match
Regular expressions can express alternatives and boundaries, but every additional exception increases maintenance work. Keep the expression readable, group alternatives with parentheses, and escape punctuation when it has a special regular-expression meaning. After each change, test a known matching string and a normal string so that a typo does not silently disable the filter or block legitimate traffic.
Do not assume that a product name is unique. Browser extensions, monitoring services, and legitimate crawlers can include similar words. Compare the complete logged header, request paths, frequency, and behavior before adding a token. If an identifier changes frequently, a static expression will require constant updates and may be the wrong control.
Crashes, 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 minuteWindows 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 reinstallAlternative: SetEnvIfNoCase with Require
You can deny a matching client without a rewrite rule by setting an environment marker and then requiring that the marker not be present:
SetEnvIfNoCase User-Agent ^NameOfBadRobot goaway
<RequireAll>
Require all granted
Require not env goaway
</RequireAll>
SetEnvIfNoCase compares the User-Agent without regard to capitalization. When the expression matches, Apache sets the goaway marker for that request. The RequireAll block grants access generally and then excludes requests carrying that marker.
Rank #4
- 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
Use this form in a context where both the environment-setting directive and the authorization directives are allowed. It has no rewrite termination flags because it makes the decision during authorization rather than in the rewrite pass. Confirm the permitted directives with your server administrator if the configuration produces a 500 error.
Keep the environment variable name private to this purpose and use the same spelling in both directives. If several rules set different markers, document their relationship so a later administrator does not accidentally grant access by changing the authorization block. This approach is most useful when the site’s access policy is already expressed with Apache 2.4 authorization directives.
Rewrite and authorization approaches compared
| Aspect | RewriteCond and RewriteRule |
SetEnvIfNoCase and Require |
|---|---|---|
| Input | %{HTTP_USER_AGENT} tested by a regular expression |
User-Agent tested by SetEnvIfNoCase |
| Typical result | [F] returns HTTP 403 |
Authorization denies requests carrying the environment marker |
| Processing control | [L] stops the current rewrite round; Apache 2.4 also provides [END] |
No rewrite termination flag; the decision is made by Require |
| Scope | Entire directory context or a path pattern such as ^private/ |
The directory or protected context containing the directives |
| Case handling | Add the [NC] flag |
Case-insensitivity is part of SetEnvIfNoCase |
| Maintenance concern | Keep the deny rule ahead of broad rewrites and preserve existing routing rules | Keep the environment name and authorization block consistent |
| Spoof resistance | Weak: the header is controlled by the client | Weak: the header is controlled by the client |
Neither implementation authenticates a crawler. Select between them according to the directives your host permits and the way the site’s existing configuration is organized. A 403 is explicit and easy to observe, while application handling or a redirect would produce different behavior and should not be substituted accidentally for a deny rule.
Understand [L] versus [END]
[L] means “last” for the current rewrite pass. In .htaccess, Apache can re-enter per-directory rewriting after an internal rewrite, so later rounds may still occur. On Apache 2.4, [END] is available when you need to stop all further per-directory rewrite processing for the request.
Do not replace every [L] with [END] automatically. Review the site’s rewrite flow first. A front controller may rely on another round to map a URL, while a security deny rule may need to prevent any re-entry. Use the flag that matches the intended control flow and the Apache version installed on the server.
Troubleshoot common failures
The blocked client still receives the page
- Confirm the request actually sends the spelling you matched. Inspect access logs instead of relying on a product name or a remembered value.
- Check that
RewriteEngine Onappears in the same applicable context and thatmod_rewriteis loaded. - Verify that the directory permits the required overrides. An
AllowOverridepolicy can make Apache ignore or reject directives in the file. - Look for a path mismatch. In a subdirectory file, the parent directory is removed before the rule pattern is evaluated.
- Move the block ahead of broad catch-all rewrites if an earlier rule routes the request elsewhere.
- Check whether a reverse proxy or CDN is serving a cached response or terminating the request before it reaches this Apache instance.
Legitimate traffic is denied
- Inspect the regular expression for short or common fragments. Replace them with a distinctive identifier.
- Remember that
[NC]deliberately treats capitalization differences as equal. - Test a normal browser User-Agent after every change and review the access log for false positives.
- If you used a path restriction, check that the pattern does not include a directory prefix already removed by per-directory processing.
Apache returns HTTP 500
- Read the error log for the exact line and directive Apache rejected.
- Check for a missing module, an override policy that disallows the directive, or a malformed regular expression.
- For the authorization approach, verify that the
SetEnvIfNoCaseandRequiredirectives are valid in that location. - Restore the backup if the site is unavailable, then reintroduce one change at a time.
The rule appears to work, but the application still logs requests
A rewrite deny rule should terminate processing for a matching request, but inspect the actual response and server logs rather than assuming that an application log entry proves the rule failed. Proxies, caches, and other layers may generate their own records; isolate the Apache response while testing.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Why User-Agent blocking is not security
“Any technique that relies on the USER_AGENT string can be trivially circumvented, since that string can be changed by the client.” — Apache HTTP Server documentation, “When not to use mod_rewrite”
A bot that changes one header can bypass either method above. The rules are useful for reducing noise from self-identifying crawlers, stopping simple scanners, or protecting a low-risk subtree from clients that follow the convention. They are unsuitable for authentication, access control based on identity, or stopping a sustained attack.
Best Value
- 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.
For persistent abuse, Apache recommends considering a higher-level control such as a firewall. Depending on the threat, you may also combine IP reputation checks, rate limiting, authentication, application-level bot controls, or a CDN/WAF. Those controls address different signals and should be selected for the traffic pattern; adding a User-Agent expression alone does not make them unnecessary.
Do not treat a 403 as proof that an attacker has been stopped. It only describes the response from this Apache layer for requests that match the expression. A determined client can change the header, use another network address, or avoid the affected URL scope. Strong access control should rely on credentials, network policy, or another signal that the client cannot freely rewrite.
Operational checklist
- Identify the exact User-Agent fragment in access logs and decide whether a prefix anchor is appropriate.
- Confirm Apache version,
AllowOverridepermissions, and the availability ofmod_rewriteor the authorization directives required by your chosen method. - Back up the existing
.htaccess, including CMS or framework front-controller rules. - Choose the file and path pattern that give the intended scope: document root for broad coverage, or a directory-specific pattern such as
^private/. - Insert the deny rule before broad rewrites when using
mod_rewrite. - Send a request with the target User-Agent and verify the forbidden response.
- Send a request with a normal User-Agent and verify that ordinary routing still works.
- Inspect the Apache error log, correct false positives or syntax errors, and only then apply the change more broadly.
- Reassess the rule if the unwanted client changes its header; move to IP, rate, authentication, application, firewall, or WAF controls when the threat is determined or sustained.
Frequently Asked Questions
Can I block several User-Agents in one rule?
Yes. Put alternatives inside one grouped expression, separated by |, such as (BadBot|AnotherBot). Add only distinctive values that your logs support, because broad fragments can block legitimate clients.
Why does ^private/ not work in an .htaccess file inside the private directory?
Apache removes the directory prefix before evaluating a per-directory RewriteRule. In a file already inside private, match ^ or a filename such as ^report.pdf$ instead.
Should I use [L] or [END]?
[L] stops the current rewrite round. Apache 2.4’s [END] stops further per-directory rewrite processing for the request. Keep [L] when the existing routing depends on another round; use [END] only after reviewing that flow.
Does this verify that a crawler really is Googlebot or another named bot?
No. User-Agent is client-controlled and can be changed trivially. These rules filter self-identifying or low-effort clients; they are not authentication or reliable crawler identity checks.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →What if my host gives a 500 error after I add the rule?
Read the Apache error log, then check module availability, AllowOverride permissions, regular-expression syntax, and whether every directive is valid in that directory. Restore your backup if the site is unavailable and reintroduce one change at a time.
Can I block only a sensitive directory?
Yes. In the document-root context, use a pattern such as ^private/. Alternatively, place the rule in the directory’s own .htaccess file and account for the removed directory prefix.
What should I use when the client keeps changing its User-Agent?
Move beyond the header: consider IP reputation or access rules, rate limiting, authentication, application-level controls, a firewall, or a CDN/WAF. Apache specifically recommends a higher-level control such as a firewall for sustained attacks.
The Bottom Line
Use RewriteCond %{HTTP_USER_AGENT} with RewriteRule ^ - [F,L] for a straightforward 403 block, or use SetEnvIfNoCase with Require when authorization directives fit your host. Confirm overrides and modules, choose the correct per-directory scope, place rewrite rules before catch-alls, and test matching and normal requests. Because User-Agent is self-declared, treat this as a low-effort filter—not a security boundary.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →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.




