Thanksgiving DealsAmazon USThanksgiving week: Black Friday picks start earlyAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCThanksgiving DealsAmazon USDo not wait for the rush - compare today's dealsAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog

How to Activate mod_rewrite and mod_speling in Apache: Ubuntu and Generic Builds

By Freedom251 Team · · 12 min read

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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To activate mod_rewrite and mod_speling on Ubuntu or Debian-style Apache2, run sudo a2enmod rewrite speling, check the configuration, and restart Apache with sudo systemctl restart apache2.service. Then turn on each feature in the configuration scope where you need it: RewriteEngine On enables rewrite rules, while CheckSpelling On enables spelling correction. Generic Apache installations without a2enmod use LoadModule directives instead. The commands below show both approaches, how to verify that the modules loaded, and how to avoid common .htaccess, DAV, and performance problems.

What does activating these Apache modules actually do?

Apache treats module loading and feature activation as separate jobs. Loading a module makes its directives available to the server; it does not automatically turn on rewriting or spelling correction in every virtual host. You must enable the appropriate directive in the server, virtual-host, directory, or permitted .htaccess context.

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.

mod_rewrite supplies a rule engine that can internally map a URL to a file, redirect a client to another URL, or invoke an internal proxy request. Apache’s documentation calls The RewriteRule directive … the real rewriting workhorse. A loaded module still needs RewriteEngine On before rewrite rules can run.

mod_speling looks for close matches when a requested file or directory name differs by capitalization or a minor spelling error. If Apache finds one close match, it can issue a permanent redirect; if it finds several, it can return a multiple-choice response. It does not correct misspelled usernames or arbitrary application data.

Popular on Amazon
Sale
Silkland 40Gbps USB C 90 Degree Right Angle Adapter 2 Pack, 240W USB4 | Male to Female Extender, 8K@60Hz, Thunderbolt 4/3, Steam Deck, ROG Ally, MacBook, Switch 2, iPhone 18/17/16/15, Quest 3 VR
  • 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
  • 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
  • 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
  • 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
  • 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.

What do I need before enabling the modules?

  • Shell access with sudo privileges, or administrator access to the Apache host.
  • The Apache service name and configuration layout used by your operating system.
  • A backup or version-controlled copy of the Apache configuration files you will edit.
  • A test URL and, for rewrite work, a clear understanding of whether a rule belongs in the main server, a virtual host, a directory block, or .htaccess.

Ubuntu’s packaged Apache uses dynamically loaded modules and the a2enmod helper. Other distributions and source builds may use a different service name, a different module directory, or statically compiled modules. The Apache configuration guide explains that the active configuration is assembled from the files and includes selected by that installation, so do not assume that an Ubuntu path exists on another platform.

How do I activate both modules on Ubuntu or Debian?

Use this sequence on a Debian-family system that provides a2enmod:

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.
  1. Enable the packaged modules.

    sudo a2enmod rewrite speling

    The utility name is speling (one l after the “spe”), matching Apache’s module naming. Ubuntu’s Apache2 module guide describes a2enmod as the way to enable modules by creating links from the available module configuration into /etc/apache2/mods-enabled. The a2enmod manpage documents the command’s enable and disable behavior.

  2. Check syntax before applying the change.

    sudo apache2ctl configtest

    A successful check normally prints Syntax OK. Fix any reported error before restarting; a typo in a module file or another configuration include can prevent Apache from starting.

  3. Restart Apache.

    sudo systemctl restart apache2.service

    Ubuntu’s documentation uses a service restart after module changes. A restart guarantees that the new module set is loaded by every worker. If your environment is production-sensitive, schedule the restart and watch the service status immediately afterward.

  4. Confirm that both modules are loaded.

    apache2ctl -M | grep -E 'rewrite|speling'

    You should see entries containing rewrite_module and speling_module. Without grep, run sudo apache2ctl -M and inspect the complete list. Apache documents the -M option as the module-listing command. On systems that expose the generic binary, httpd -M performs the equivalent check.

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

At this point the modules are loaded, but no behavior is enabled until you add RewriteEngine On and/or CheckSpelling On in an allowed configuration context.

How do I activate the modules on a generic Apache build?

If the installation does not provide a2enmod, add the matching dynamic-load directives to the active server configuration. The exact file and module path depend on how Apache was packaged or compiled:

Also popular on Amazon
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule speling_module modules/mod_speling.so

These lines use Apache’s module identifiers, rewrite_module and speling_module. A packaged build may require an absolute path such as /usr/lib/apache2/modules/mod_rewrite.so; use the path supplied by that installation rather than copying an Ubuntu path to another operating system. Place the directives in the main configuration or an included file that is read before the directives using the modules.

Run the platform’s configuration test after editing. Common controls include apachectl configtest or httpd -t, followed by the service manager command used by that system. Then verify with httpd -M (or the local Apache control wrapper) and look for the two module identifiers.

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

Some builds compile a module statically. A statically compiled module will not appear as a separate LoadModule line to add; it is already part of the server binary. If a needed module was not compiled in and dynamic loading is unavailable, enabling or removing it requires rebuilding Apache with the module selected.

How do I turn on rewriting after loading mod_rewrite?

Add RewriteEngine On in the scope where the rules should operate, then add rules appropriate to that scope. A minimal virtual-host example is:

<VirtualHost *:80>
    ServerName example.test
    DocumentRoot /var/www/example

    RewriteEngine On
    RewriteRule ^old-page$ /new-page [R=301,L]
</VirtualHost>

The rule above redirects a request for /old-page to /new-page. In a server or virtual-host context, the pattern is matched against the URL path beginning with a slash in the request processing model; in a per-directory context, Apache removes the directory prefix before matching. That distinction is why a rule copied from one context may not behave as expected in another.

For a directory block, enable the engine in that block:

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.
<Directory /var/www/example>
    Options FollowSymLinks
    AllowOverride None
    RewriteEngine On
    RewriteRule ^index.html$ / [R=301,L]
</Directory>

Directory-level rewriting requires at least one of FollowSymLinks or SymLinksIfOwnerMatch. Apache does not allow those options to be set from .htaccess unless the server’s AllowOverride policy permits the relevant option class.

In an .htaccess file, the host administrator must allow overrides for the directory. A typical example is:

Also popular on Amazon
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<Directory /var/www/example>
    AllowOverride FileInfo Options
</Directory>

Then the file can contain:

RewriteEngine On
RewriteRule ^old-page$ /new-page [R=301,L]

The exact AllowOverride classes and security policy should be chosen by the administrator. If overrides are disabled, Apache will return a 500 error when it encounters a forbidden directive; move the rule into the virtual-host configuration instead of weakening policy blindly.

How do I turn on spelling correction with mod_speling?

Set CheckSpelling On in the directory, virtual-host, server, or permitted .htaccess scope where correction is wanted:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<Directory /var/www/example>
    CheckSpelling On
</Directory>

After loading the module and enabling this directive, a request such as /Docs/Install.html can be matched to an existing path whose capitalization differs. A minor filename or directory typo may also be corrected when Apache finds a close match. If more than one candidate is equally close, Apache can return a multiple-choice response rather than guessing.

Keep the setting narrow when possible. Enabling it for one documentation directory is easier to reason about than enabling it across a large site, and it avoids making correction behavior part of unrelated application routes.

Should I enable both features in the same configuration scope?

Only when the same URL space genuinely needs both behaviors. The modules are independent: a site can use rewrite rules without spelling correction, or spelling correction without any rewrite rules. A combined example is:

<Directory /var/www/example>
    Options FollowSymLinks
    RewriteEngine On
    CheckSpelling On
    RewriteRule ^legacy/(.*)$ /archive/$1 [R=301,L]
</Directory>

Use explicit rewrite rules for intentional URL migrations, canonical redirects, and application routing. Use mod_speling as a recovery mechanism for human-entered filename and directory variations, not as a substitute for designing stable URLs. If a rewrite rule and a spelling correction could both act on the same request, test the order and result with a representative URL; an unexpected redirect chain is harder to debug than a single canonical rule.

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

How can I verify that each module works?

Verify in layers so a failure points to the right part of the setup.

  1. Verify loading: run apache2ctl -M or httpd -M and confirm rewrite_module and speling_module.
  2. Verify syntax: run sudo apache2ctl configtest (or the equivalent control command) after every configuration edit.
  3. Verify service state: check the service status with your operating system’s service manager and inspect the Apache error log if the restart fails.
  4. Verify rewrite behavior: request a deliberately simple test path covered by a temporary rule, then remove or replace that rule after confirming the expected redirect or internal mapping.
  5. Verify spelling behavior: request a known file with a capitalization difference or minor typo in the directory where CheckSpelling On is set. Confirm the response and the final URL rather than assuming that a browser’s cached redirect proves the current configuration.

Use command-line clients when you need to see redirects clearly, for example curl -I http://example.test/old-page. A 301 response indicates a permanent redirect; an internal rewrite may leave the browser’s address unchanged while serving a different resource.

Also popular on Amazon
Sale
BENFEI USB C Hub 5-in-1 with 4K HDMI(Certified), 100W Power Delivery, 3 USB-A, Silicone Cable, Aluminum Case Compatible with MacBook Pro/Air, iPad Pro, iMac, iPhone 15 Pro/Pro Max, XPS, Thinkpad
  • Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
  • Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
  • 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
  • 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
  • Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.

Why does Apache say the module or directive is unknown?

An “Invalid command” or “unknown directive” error usually means the module was not loaded in the configuration being tested, or the directive is outside a context where it is allowed. First inspect the module list, then confirm that the LoadModule line or Ubuntu module link belongs to the active Apache installation. Multiple Apache versions on one host can make a command inspect a different binary from the service that serves traffic.

If the module appears in -M but the directive is rejected, check the directive’s context in the mod_rewrite documentation or mod_speling documentation. A directive placed in .htaccess may be disallowed by AllowOverride; move it to a virtual-host or directory block, or have the administrator permit the required override class.

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

What should I do if a restart fails after enabling a module?

Do not repeatedly restart a failing service. Run the configuration test and read the exact file and line number in its error. Common causes include a misspelled module path, loading a module compiled for a different Apache version, duplicate directives, or placing a directive in a context that does not support it.

Restore the last known-good configuration if the service must return immediately, then correct one change at a time. On Ubuntu, a2dismod rewrite or a2dismod speling can remove the corresponding module link when you need to roll back a packaged-module change; consult the Ubuntu tool documentation for the supported syntax. Disabling a module does not remove rewrite or spelling directives from your configuration, so remove or comment out those directives before restarting again.

What are the important mod_speling safety and performance limits?

Apache warns against enabling mod_speling in directories served by WebDAV. A misspelled upload name could be matched to an existing filename and redirected, producing behavior that is unsafe for write-enabled content. Keep spelling correction away from DAV upload areas unless you have a specific, reviewed reason to combine them.

The module scans directory entries when it searches for a correction. On directories containing many files, that work can add overhead for requests that need correction. It can also expose an unintended match if the document tree contains files that should not be discoverable by near-spelling requests. Do not place secrets, backups, or private configuration files under a web-accessible directory and rely on spelling behavior to hide them.

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

Remember that the feature corrects file and directory names. It does not repair a misspelled account name, database key, API endpoint parameter, or other application-level value.

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

How should I troubleshoot mod_rewrite without slowing the server?

Start with one rule and a narrow test URL. Confirm the rule’s context, pattern, substitution, and flags before adding conditions or complex regular expressions. Check the response headers with curl and inspect the normal Apache error log for syntax or processing errors.

Also popular on Amazon
𝟒𝐏𝐚𝐜𝐤 𝐔𝐩𝐠𝐫𝐚𝐝𝐞𝐝 USB to USB C Adapter,Type-C Female to A Male Charger Converter for iPhone 18 Charger,iWatch Ultra SE 9 10,iPhone 17 Pro Max 16 15 14,Samsung S25,AirPods,iPad,Car,Xbox
  • 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
  • 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
  • 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
  • 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
  • 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.

Apache provides rewrite trace logging for difficult cases, but the official documentation warns that detailed tracing can slow Apache dramatically; use a level above trace2 only while debugging and turn it off afterward. Do not leave verbose tracing enabled on a busy production server. Prefer a temporary, targeted diagnostic configuration and restore the normal log level when the request path is understood.

When should I use a2enmod, LoadModule, or a static build?

Installation type Module activation Feature activation What to verify
Ubuntu/Debian package sudo a2enmod rewrite speling RewriteEngine On and/or CheckSpelling On apache2ctl -M, config test, service restart
Generic dynamic build Matching LoadModule directives with installation-specific paths Same directives in an allowed context httpd -M (or local wrapper), config test, platform service control
Static build Already compiled into the Apache binary; no load line Same directives in an allowed context Module listing and the build’s configuration documentation

The table describes activation methods, not competing products. Choose the method that matches the Apache package actually serving requests. Paths and service names vary by distribution and release, so confirm them against the installed package before editing.

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

How do I disable the modules or remove their behavior?

To stop behavior while keeping the modules available, set RewriteEngine Off and CheckSpelling Off in the relevant scope, or remove those directives and rules. This is useful when you want to retain the module for a later virtual host but disable it for one site.

To disable the modules themselves on Ubuntu/Debian, run:

sudo a2dismod rewrite speling
sudo apache2ctl configtest
sudo systemctl restart apache2.service

On a generic build, comment out or remove the corresponding LoadModule directives, test the configuration, and restart through that platform’s service manager. Any remaining RewriteRule, RewriteEngine, CheckSpelling, or related directive can then cause a syntax failure, so remove or relocate those settings as part of the rollback.

What is the safest activation pattern for a production site?

  1. Identify the exact Apache binary and service that serve the site.
  2. Back up the active configuration and record the current module list.
  3. Enable only the required module(s), using a2enmod or the installation’s LoadModule mechanism.
  4. Run the configuration test before restarting.
  5. Enable directives in the narrowest suitable scope, preferably a virtual host or directory rather than global configuration.
  6. Test a controlled URL for the expected redirect, internal mapping, or spelling correction.
  7. Watch logs and service status after the restart, then remove temporary test rules and verbose diagnostics.

This sequence separates a module-loading problem from a rule or directive problem and limits the blast radius of an incorrect setting.

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

Frequently Asked Questions

Can mod_speling preserve query strings when it redirects a misspelled path?

Query-string handling depends on the resulting redirect and the surrounding Apache configuration, so inspect the actual Location header rather than assuming application parameters were preserved. Test representative URLs that include query parameters before relying on correction for links used by clients or search engines.

Does mod_rewrite work on a case-sensitive Linux filesystem?

Yes. Rewrite rules match the URL and then apply the substitution you specify; they do not make the underlying filesystem case-insensitive. If you need case normalization, write an explicit canonical rule and make sure it cannot create a redirect loop.

Why does a browser keep showing an old redirect after I changed the rule?

Permanent redirects can be cached by browsers and intermediaries. Recheck with a command-line request or a private browser session, and use a temporary redirect while developing a rule so an incorrect result is easier to replace.

Can I load the modules without granting users .htaccess access?

Yes. Load the modules and place the directives in the main server, virtual-host, or directory configuration while keeping AllowOverride None for untrusted directories. This centralizes review and avoids allowing per-directory users to change rewrite behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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. Prices as of November 23, 2026 11:29 am GMT+0530.

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.