Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Use mod_rewrite to map a requested URL to another resource without changing what the visitor sees, or return a deliberate 3xx redirect that changes the browser’s address. Turn it on with RewriteEngine On, place rules in the right Apache context, order specific rules before catch-alls, and choose termination and redirect flags deliberately.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The same-looking rule can behave differently in a virtual-host configuration and in .htaccess. The difference is the rewrite phase, the directory prefix, and whether Apache re-enters per-directory processing. The examples below show how to write, test, and secure rules in both environments.
As an Amazon Associate I earn from qualifying purchases.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsWhat mod_rewrite actually does
Apache’s mod_rewrite is a rule-based URL manipulation engine. Apache evaluates each RewriteRule in order. A RewriteCond placed immediately before a rule restricts whether that rule is allowed to run. The rule’s substitution can either map the request internally to another resource or send an external redirect response to the client. See the Apache mod_rewrite introduction for the processing model.
An internal rewrite is a server-side decision: Apache serves a different file or application route while the browser continues to display the original URL. An external redirect is an HTTP response: the browser receives a 3xx status and then requests the destination, so the address bar changes.
#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.
| Decision | What the browser sees | Typical use | Example |
|---|---|---|---|
| Internal rewrite | Original URL remains visible | Map a clean route to a script or front controller | ^about$ about.php [END] |
| External redirect | Address changes after a 3xx response | Move an old URL to its canonical replacement | ^about-old$ /articles/about [R=301,END] |
A redirect is not merely an alternative spelling of a rewrite. It creates another client request and has cache and permanence consequences, while an internal rewrite stays within the current server request.
Choose the Apache configuration context first
The location of a rule determines when Apache evaluates it and what text the pattern matches. Apache documents these differences in its technical details for mod_rewrite.
Virtual-host or main-server configuration
When you administer Apache, put site-wide or virtual-host rules in the server or virtual-host configuration. They run in the main rewrite processing phase, before per-directory rewriting. This gives you clearer control over the request flow and avoids relying on distributed override files.
.htaccess per-directory configuration
Use .htaccess when the hosting arrangement does not give you access to the main configuration. Apache must permit the required directives through its AllowOverride settings; if overrides are disabled, a syntactically correct file will not take effect.
In per-directory context, Apache removes the directory prefix before matching a RewriteRule. A rule in the document root therefore normally matches about, not /about. A file in a subdirectory sees a path relative to that directory. This is the most common reason a rule copied from a virtual-host configuration fails in .htaccess.
| Where the rule lives | Processing behavior | Pattern guidance | Best fit |
|---|---|---|---|
| Server or virtual-host configuration | Main rewrite phase | Use the URL path form expected by that context | Administrators who control Apache |
Document-root .htaccess |
Later per-directory phase; directory prefix stripped | Usually omit the leading slash and directory prefix | Restricted hosting access |
Nested .htaccess |
Per-directory processing for that directory | Match the path relative to the nested directory | Rules local to a subtree |
Adapt examples to the context
The same logical mapping can need a different pattern or substitution in a virtual host than in .htaccess. Do not add a leading slash simply because the browser displays one. Confirm the path Apache presents to the rule in the context where it runs.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Prerequisites and a safe starting file
- Apache must have
mod_rewriteloaded and the relevant rewrite directives permitted in the chosen context. - Start with a backup of the active virtual-host configuration or
.htaccessfile. - Make one logical change at a time so a failing request can be tied to a specific rule.
- Test a non-destructive URL before replacing a broad routing rule.
A minimal rule set begins by enabling the engine:
RewriteEngine On
In a document-root .htaccess, that line is followed by rules whose patterns usually omit the leading slash. In server configuration, use the path syntax required by that configuration context.
Understand the anatomy of a rewrite rule
RewriteRule Pattern Substitution [Flags]
Pattern
The pattern is matched against the URL path presented in the current context. In per-directory processing, the directory prefix has already been removed. Anchors such as ^ and $ make a rule apply to the complete intended path rather than an accidental substring.
Substitution
The substitution is the resource or URL Apache should use when the pattern matches. A relative substitution commonly names a local resource for an internal mapping. A path beginning with / is an absolute URL-path on the same host for a redirect example. Keep substitutions constrained to the resources and hosts your application actually intends to expose.
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
Flags
Flags change what happens after a match. Separate multiple flags with commas inside brackets. The flags most relevant to URL rewriting are:
| Flag | Effect | Use carefully when |
|---|---|---|
L |
Stops the current round of rewrite processing. | Later rules in the same round must not run. |
END |
Stops all per-directory rewrite processing. | You need to prevent a new per-directory pass, especially in .htaccess; confirm support in the Apache version deployed. |
R=301 |
Sends a permanent redirect response. | The old URL has permanently moved and clients should use the new one. |
PT |
Passes the result back through URL mapping so directives such as Alias can act on it. |
The rewritten result must participate in another URL-to-resource mapping stage. |
Apache’s complete flag behavior is documented in the RewriteRule flags reference.
Write the two fundamental URL mappings
Internal rewrite: keep /about in the address bar
RewriteEngine On
RewriteRule ^about$ about.php [END]
When the request matches the complete path about in the applicable context, Apache serves about.php internally. The visitor continues to see /about. In a context where END is unsuitable or unavailable, use the termination behavior appropriate to that Apache version and processing phase.
Permanent redirect: move an old path
RewriteEngine On
RewriteRule ^about-old$ /articles/about [R=301,END]
This sends a permanent redirect, so the client requests /articles/about and displays that new path. Use a permanent status only after the mapping is verified; changing a cached permanent redirect can be difficult for visitors and intermediaries.
Do not confuse the two outcomes
- Choose an internal rewrite when the public URL is already the URL you want people to bookmark, while the application resource has a different internal name.
- Choose a redirect when clients must learn a new canonical URL, such as after a deliberate content move.
- Do not add
R=301merely to make an internal route work; it changes the browser-visible behavior.
Use conditions for metadata and resource checks
A RewriteCond applies to the next RewriteRule, and conditions are evaluated as part of deciding whether that rule runs. Use them when the decision depends on request metadata or whether a resource already exists.
Recommended Free Tools
Protect existing files and directories
A common application-router design lets Apache serve real files and directories normally, then sends only the remaining paths to an application. The exact condition and substitution must match the site’s layout, but the structure is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ app.php [END]
The two exclusions mean “not an existing file” and “not an existing directory.” Verify that the application entry point and the path seen by Apache match your deployment before using this pattern. A broad catch-all placed before these exclusions can intercept assets or directories unintentionally.
Keep conditions attached to the intended rule
Because a condition governs the following rule, place each condition immediately above the rule it qualifies. Conditions do not form a global filter for every rule below them. If several rules need the same test, repeat it deliberately or reorganize the rules so the scope is obvious.
Order narrow rules before broad ones
Apache evaluates rules sequentially. Put canonicalization rules and explicit exclusions before a broad application route. Otherwise, the catch-all can consume a request before the specific redirect or file check has a chance to run.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →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)
Prevent rewrite loops and accidental re-entry
Rewrite loops occur when a substitution causes Apache to evaluate a path that matches the same rule again. They are especially easy to create in .htaccess, where per-directory processing can happen again after an internal mapping.
Use complete matches
Anchor rules to the exact route they are intended to handle. For example, ^about$ cannot also match about/team. Avoid an unbounded catch-all until the explicit routes, file exclusions, and termination behavior are working.
Choose L or END for the intended scope
L stops the current round, but it does not necessarily prevent another per-directory round. END stops all per-directory rewrite processing and is useful in .htaccess when an internal route would otherwise re-enter the rules. The correct choice depends on the processing context and Apache version.
Keep redirect targets outside the redirect pattern
A redirect rule should not send the request to another URL that satisfies the same redirect condition. If an old path redirects to a canonical path, make the old-path pattern specific enough that the canonical path does not match it.
Free tools Windows power users keep installed
One-click scans. No signup required.
Diagnose the first redirect, not the last browser error
Use a client that shows response headers and inspect each request in sequence. A loop is usually visible as the same small set of paths alternating, or as a path that repeatedly gains and loses a prefix. Correct the first rule that changes the request unexpectedly, then retest with a fresh client session.
Security rules for substitutions and redirects
Prevent open redirects
Never build a redirect destination from unvalidated user input. Apache warns: “If a RewriteRule constructs a redirect URL using unvalidated user input, an attacker can craft a link that redirects visitors to a malicious site while appearing to originate from your domain.” The warning appears in the mod_rewrite introduction.
Prefer a fixed relative path or a destination selected from a server-side allowlist. If a query parameter or path segment influences the destination, validate it before it reaches the substitution and reject values that introduce another host or scheme.
Do not expose an arbitrary proxy target
User-controlled backreferences must not select arbitrary targets for the [P] proxy behavior. Doing so can turn the rewrite rule into a server-side request forgery path, allowing the server to make requests to destinations the visitor should not control.
Constrain filesystem mappings
A broad capture such as (.+) can accept more path material than intended when request data is mapped to the filesystem. Use restrictive character classes and explicit route shapes. Normal Apache <Directory> protections still matter; a rewrite rule is not a replacement for filesystem authorization.
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
Treat backreferences as untrusted data
Captures from the requested URL can contain unexpected characters or encodings. Use them only where the target format is constrained, and do not let a captured value determine an external host, proxy destination, or unrestricted filesystem path.
Build a maintainable rule set
Separate canonicalization from application routing
Put host or path canonicalization rules first, then explicit legacy redirects, then existing-file and existing-directory exclusions, and finally the application’s broad route. This ordering follows Apache’s sequential evaluation model and makes each responsibility visible.
Comment the intent, not the obvious syntax
Explain why a rule exists, which context it belongs to, whether the destination is internal or external, and whether the redirect is intentionally permanent. Comments that only restate “rewrite about to about.php” do not help when the site changes.
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 reinstallKeep context-specific files context-specific
A rule copied from a virtual-host file may require a different pattern in .htaccess. Record the file location next to deployment documentation so a future change does not reintroduce a leading-slash or directory-prefix error.
Use termination flags consistently
Choose a convention for internal routes and document why it exists. Mixing L and END without understanding their scope can make one route stop while another re-enters, producing behavior that appears random.
Deployment workflow
- Select the context. Use the virtual-host or main-server configuration when you administer Apache. Use
.htaccessonly when main configuration access is unavailable and overrides permit the needed directives. - Enable the engine. Add
RewriteEngine Onin the selected context. - Start with one exact route. Test a narrow internal rewrite such as
^about$ about.php [END]before adding conditions or a catch-all. - Verify the response type. An internal rewrite should serve the target while retaining the requested URL; a redirect should return a 3xx response and cause a second client request.
- Add explicit redirects. Place legacy-to-canonical mappings before broad routing and use
R=301only for a confirmed permanent move. - Add exclusions. Protect existing files and directories before the application route if the site uses a front controller.
- Review loop boundaries. In
.htaccess, decide whetherENDis needed to prevent another per-directory pass. - Test hostile inputs. Try unexpected path segments, encoded characters, absolute-looking destinations, and values that could become proxy or filesystem targets. Confirm they are rejected or safely constrained.
- Document the final order. Record which rules are canonicalization, redirects, exclusions, and application routing so later edits preserve their dependencies.
Troubleshooting by symptom
The rule works in the virtual host but not in .htaccess
Check the pattern first. In per-directory context the directory prefix is stripped, so remove the leading directory path and usually the leading slash. Then confirm that AllowOverride permits the directives and that RewriteEngine On is present in the active file.
The browser changes URL when it should not
Look for an R flag or another rule issuing a redirect. Remove the redirect flag for an internal mapping and ensure that the substitution is not an absolute external URL.
The browser keeps the old URL when it should change
A substitution without R is an internal rewrite. Add an intentional redirect status, such as R=301 for a permanent move, and verify that the target does not match the source rule.
Every request returns a redirect loop
Inspect the sequence of locations returned by the server. Check for a rule whose destination still matches its own pattern, a canonicalization rule that alternates between two forms, or a per-directory re-entry that L did not stop. Tighten the pattern and use END where complete per-directory termination is required and supported.
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.
Images or directories are routed to the application
Move the existing-file and existing-directory conditions above the catch-all rule. Confirm that the conditions use the correct request filename for the directory layout; a condition copied from another site can exclude the wrong resources.
An alias no longer resolves after rewriting
If the rewritten result must pass through Apache’s URL mapping so an Alias can act on it, use the PT flag where appropriate. Check the mapping order and ensure the substitution is the URL-path expected by the alias.
A redirect can be weaponized
Find any user-controlled value reaching the redirect substitution. Replace unrestricted concatenation with a fixed relative destination or an allowlisted value. Apache’s security guidance treats unvalidated redirect construction as an open-redirect risk.
A proxy rule reaches internal services
Do not let user-controlled backreferences select a [P] target. Restrict proxy destinations to trusted, fixed endpoints and remove proxy behavior from general-purpose path captures.
Practical rule patterns
One clean route to one script
RewriteEngine On
RewriteRule ^profile$ profile.php [END]
This is appropriate when the public route is fixed and the implementation file should remain hidden from the browser.
One old route to one new route
RewriteEngine On
RewriteRule ^legacy-news$ /news [R=301,END]
Use this only when /legacy-news has permanently moved to /news. Keep the source pattern exact so the destination cannot trigger the same redirect.
Application fallback after real resources
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [END]
This sends non-file, non-directory paths to an application entry point. Replace index.php with the actual entry point and test static assets, directory indexes, and error handling before deploying.
How to decide between the main configuration and .htaccess
If you control the virtual host, prefer that configuration for predictable processing and centralized review. It keeps rewrite policy with the site definition and avoids the per-directory prefix and re-entry behavior that complicate debugging.
If the host denies main-configuration access, .htaccess is the practical option identified in Apache’s URL remapping guide. Confirm override permissions, write patterns relative to the directory, and use termination behavior that accounts for per-directory processing.
| Question | Choose server or virtual-host configuration when… | Choose .htaccess when… |
|---|---|---|
| Who controls Apache? | You administer the site’s Apache configuration. | The hosting arrangement withholds main configuration access. |
| Where should policy live? | In a centrally managed virtual-host or server definition. | In a directory-local file permitted by AllowOverride. |
| What must you watch? | Main-phase ordering and URL-path syntax. | Stripped directory prefixes, later processing, and re-entry. |
Reference checklist before publishing a rule
- Is
RewriteEngine Onactive in the context that handles the request? - Does the pattern match the path form for that context, especially in
.htaccess? - Is the result intentionally internal or intentionally a redirect?
- If it redirects, is the status code and permanence appropriate?
- Are narrow rules, canonicalization, and exclusions above broad catch-alls?
- Could the substitution cause another per-directory pass or match the same rule again?
- Are existing files and directories protected where the application router requires it?
- Can any user-controlled value create an external host, a proxy target, or an unrestricted filesystem path?
- Does the rule need
PTso anAliascan process the result? - Have you tested both the expected request and malformed or hostile variants?
For directive semantics and context-specific behavior, consult Apache’s mod_rewrite introduction, technical details, remapping guide, and flags reference.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.




