Apache HTTP server

Prev Next

Plans supporting this feature: Professional Business Enterprise

To host your Document360 knowledge base in a subfolder (such as example.com/docs) using the Apache HTTP server, specific configurations are required. This article walks you through the necessary steps to enable required Apache modules, configure proxy and redirect rules, and manage paths for articles, APIs, and sitemaps. It also explains how to prevent duplicate content issues in search engines by correctly handling URL redirection.

NOTE

Replace the example domain with your document360 provided domain/custom domain.

  • Example domain represented using example.document360.io

  • Subfolder/subdirectory path (/v1) represented as example.document360.io/v1

  • Subfolder/subdirectory home page path (/help) represented as example.document360.io/help

Setting up a subfolder path

Ensure the following Apache server modules are enabled. These modules are part of the Apache server installation.
• proxy
• proxy_http
• headers
• substitute
• proxy_html
Run the following bash command to enable the modules:

sudo a2enmod proxy proxy_http headers substitute proxy_html

Home page

  1. Configure the following Virtual Host configuration location blocks.

For example,

  • Location block - Proxy all requests where the path starts from "/help".

This block will proxy requests for the home page.

<Location /help>
   ProxyPreserveHost off
   RequestHeader set Host example.document360.io
   RequestHeader set requested-by proxy
   RequestHeader unset Accept-Encoding
   ProxyPass https://example.document360.io/v1
   ProxyPassReverse https://example.document360.io/v1

   AddOutputFilterByType SUBSTITUTE text/html
   substitute 's|href="/docs|href="/help|ni'
   substitute 's|href="/v1/docs|href="/help|ni'
   substitute 's|href="https://example.document360.io/docs|href="https://docs.example.com/help|ni'
</Location>

Redirect block to fix article preview links for subfolder hosting

  1. The article preview links in the Document360 portal contain the workspace and language slug in the URL.

For example,

  • Article URL: docs.example.com/getting-started

  • Preview links in the Knowledge base portal: docs.example.com/v1/en/getting-started

You can either add one more location block to handle /v1/en path, or have a redirect set from /v1/en to /.

Please refer to the code snippet below for setting the redirect:

RewriteEngine on
RewriteRule ^v1/en$ / [R=301,L,NC]

You should install the rewrite module for the redirection to work. Use the following code to install the rewrite module.

sudo a2enmod rewrite

Article/Category pages

  1. Configure the following Virtual Host configuration location blocks.

For example,

  • Location Block – Proxy all requests where the path starts with /help/ (for article and category pages).

  • Location Block – Proxy all requests where the path starts with /api/ (for Site API requests used in KB Site 2.0).

These blocks will proxy requests for your documentation content and API calls.

Add them to the same Apache Virtual Host configuration file.

<Location /help/>
   ProxyPreserveHost off
   RequestHeader set Host example.document360.io
   RequestHeader set requested-by proxy
   ProxyPass https://example.document360.io/docs/
   ProxyPassReverse https://example.document360.io/docs/

   AddOutputFilterByType SUBSTITUTE text/html
   substitute 's|href="/docs|href="/help|ni'
   substitute 's|href="/v1/docs|href="/help|ni'
   substitute 's|href="https://example.document360.io/docs|href="https://docs.example.com/help|ni'
</Location>

<Location /api>
  ProxyPreserveHost off
  RequestHeader set Host example.document360.io
  RequestHeader set requested-by proxy
  RequestHeader unset Accept-Encoding
  ProxyPass https://example.document360.io/api
  ProxyPassReverse https://example.document360.io/api

  AddOutputFilterByType SUBSTITUTE application/json
  substitute 's|href="/docs/|href="/help/|ni'
  substitute 's|href="/v1/docs/|href="/help/|ni'
  substitute 's|href="https://example.document360.io/docs/|href="https://docs.example.com/help/|ni'
</Location>
  1. Restart the Apache server

For example, If you are using Nginx on Linux, then use the command
$ sudo systemctl restart nginx

NOTE

  • If you are on KB Site 2.0 and wish to host your Knowledge base as a subfolder, you have to define the Subfolder path as well as the Site API path.

  • Replace /docs and /api with the exact values configured under Subfolder path and Site API path in the Document360 portal.


Sitemap generation

NOTE

Replace the example domain with your document360 provided domain/custom domain.

  • Example domain represented using example.document360.io

  • The sitemap prefix remains the same except for the language code (en, fr, de, etc.)  example.document360.io/sitemap.xml.en

<Location /sitemap.xml.en>
    RequestHeader set Host example.document360.io
    RequestHeader set requested-by proxy
    ProxyPass https://example.document360.io/sitemap.xml.en
    ProxyPassReverse https://example.document360.io/sitemap.xml.en
</Location>

What happens next?

Once you have successfully configured the web server, your knowledge base site will be live in your custom subfolder/subdirectory.

However, the existing URL for your project will serve the requests.

For example, example.document360.io and example.com/docs (if /docs is your folder path) will point to the knowledge base site.

This will cause duplicate content in Search engines (Google, Bing, etc.). To do this, you will need to enable a URL redirect.

NOTE

To enable the redirect from example.document360.io to example.com/docs, please contact us at support@document360.com.