• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache for Newbie: Set up Apache with mod_substitute

December 17, 2023

Apache for Newbie: Set up Apache with mod_substitute

Apache is one of the most popular web servers in the world, known for its flexibility and robustness. If you’re new to Apache and want to learn how to set it up with mod_substitute, this article is for you. Mod_substitute is an Apache module that allows you to modify the response content sent by the server before it reaches the client. It can be a powerful tool for rewriting or substituting text in HTML pages, XML files, or any other type of content served by Apache.

Step 1: Install Apache

The first step is to install Apache on your server. If you’re using a VPS hosting service like Server.HK, you may already have Apache pre-installed. If not, you can install it using the package manager of your operating system. For example, on a Ubuntu server, you can run the following command:

sudo apt-get install apache2

Once the installation is complete, you can start Apache by running:

sudo service apache2 start

Step 2: Enable mod_substitute

By default, mod_substitute is not enabled in Apache. To enable it, you need to run the following command:

sudo a2enmod substitute

This command will create a symbolic link in the Apache configuration directory, enabling the module.

Step 3: Configure mod_substitute

Now that mod_substitute is enabled, you can configure it to perform the desired substitutions. The configuration is done in the Apache configuration file, which is usually located at /etc/apache2/apache2.conf or /etc/httpd/httpd.conf depending on your operating system.

Open the configuration file in a text editor and add the following lines:

LoadModule substitute_module modules/mod_substitute.so

<IfModule mod_substitute.c>
    AddOutputFilterByType SUBSTITUTE text/html
    Substitute "s/foo/bar/i"
</IfModule>

The first line loads the mod_substitute module, and the following lines configure it to substitute the text “foo” with “bar” in any HTML response. The “i” flag makes the substitution case-insensitive.

Step 4: Restart Apache

After making the configuration changes, you need to restart Apache for the changes to take effect. You can do this by running:

sudo service apache2 restart

Now Apache is set up with mod_substitute, and it will perform the specified substitutions on any HTML response it serves.

Summary

Setting up Apache with mod_substitute can be a powerful way to modify the response content sent by the server. By following the steps outlined in this article, you can easily install and configure mod_substitute on your Apache server. If you’re looking for a reliable VPS hosting service to host your Apache server, consider Server.HK. Our Hong Kong VPS Hosting solutions are top-notch and provide excellent performance and support.

Recent Posts

  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  • Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  • Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  • Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?
  • How to Migrate from CentOS 8 to AlmaLinux or Rocky Linux Safely

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot