• 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 are new to Apache and want to learn how to set it up with mod_substitute, this article is for you. Mod_substitute is a powerful module that allows you to modify the response content sent by the server before it is delivered to the client. It can be used for various purposes, such as rewriting URLs, modifying HTML content, or adding headers.

Step 1: Install Apache

Before we can start using mod_substitute, we need to have Apache installed on our server. If you haven’t done so already, you can follow the instructions on the Server.HK website to set up a Hong Kong VPS hosting environment with Apache.

Step 2: Enable mod_substitute

Once Apache is installed, we need to enable the mod_substitute module. Open the Apache configuration file, usually located at /etc/httpd/conf/httpd.conf, and look for the following line:

#LoadModule substitute_module modules/mod_substitute.so

Remove the ‘#’ at the beginning of the line to uncomment it. Save the file and restart Apache for the changes to take effect.

Step 3: Configure mod_substitute

Now that mod_substitute is enabled, we can start configuring it. Open the Apache configuration file again and add the following lines:

<IfModule mod_substitute.c>
    AddOutputFilterByType SUBSTITUTE text/html
    Substitute "s|https://example.com|https://server.hk|ni"
</IfModule>

In this example, we are using mod_substitute to replace all occurrences of “https://example.com” with “https://server.hk” in the response content. The ‘s’ flag stands for substitution, and the ‘ni’ flags stand for no-case and no-inherit respectively.

Step 4: Test mod_substitute

After configuring mod_substitute, it’s time to test if it’s working correctly. Create a simple HTML file with the following content:

<html>
<head>
<title>Test Page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is a test page.</p>
</body>
</html>

Save the file as “test.html” and place it in your Apache document root directory, usually located at /var/www/html/. Access the file through your web browser and check if the text “Hello, world!” is replaced with “Hello, Server.HK!”. If it is, congratulations! You have successfully set up Apache with mod_substitute.

Summary

Setting up Apache with mod_substitute can be a powerful tool in your web development arsenal. It allows you to modify the response content sent by the server, giving you more control over how your website is displayed to the client. By following the steps outlined in this article, you can easily get started with mod_substitute and take advantage of its capabilities.

Remember, if you are looking for reliable VPS hosting in the Hong Kong, consider Server.HK. Their Hong Kong VPS hosting plans provide the perfect environment for running Apache and other web server software.

Recent Posts

  • 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
  • CentOS Server Performance Tuning: Optimization Techniques for 2026

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