Hosting Document360 on a sub-directory
  • 17 Feb 2021
  • 1 Minute To Read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Hosting Document360 on a sub-directory

  • Print
  • Share
  • Dark
    Light

Many companies host their documentation under a subdirectory on their website domain, for example: example.com/docs. This is because hosting your knowledge base on a subdirectory of a website, rather than subdomain (docs.example.com) is better for SEO.

This article will use the following platforms to show you how you can host Document360 on a sub-directory:

  • Apache
  • Nginx
  • ASP.NET Core
  • IIS Server

To host Document360 on a sub-directory

Assumptions

The following examples assume:

  • That you want to setup your documentation at mywebsite.com/docs
  • That you have working knowledge of the terminal
  • That your documentation on Document360 is hosted at helloworld.document360.io/docs.

To set up an Apache server sub-directory

  1. Ensure the following modules are installed and enabled:
    sudo a2enmod proxy
    sudo a2enmod proxy_balancer
    sudo a2enmod proxy_http
    
  2. Add the following to the site configuration file under /etc/apache2/sites-available For example: 000-default.conf
SSLProxyEngine on
ProxyPass "/docs"  “https://helloworld.document360.io/docs”
ProxyPassReverse "/docs"  “https://helloworld.document360.io/docs”
  1. Restart the Apache server
sudo systemctl restart apache2

To set up a Nginx server sub-directory

  1. Add the following location section in your Nginx configuration file (/etc/nginx/default).
location /docs {
                proxy_pass https://helloworld.document360.io/docs;
                proxy_set_header        Host helloworld.document360.io;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        X-Forwarded-Proto $scheme;
                proxy_set_header        "requested-by" "proxy";
        }
  1. Restart the server.

To set up an ASP.Net Core sub-directory

  1. Install the ASP.Net Core package
  2. In the Startup.cs file, configure the method as follows:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            /// ...

            app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/docs"),
                builder => builder.RunProxy(new ProxyOptions() {
                    Scheme = "https",
                    Host="helloworld.document360.io"
            }));
            
           /// ...

To set up an IIS Server sub-directory

  1. Install the URL Rewrite module for IIS Server

  2. Install the Application Request Routing module, and ensure its enabled

  3. Add the following rewrite rule in web.config to rewrite contents from your documentation at /docs

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rewrite">
                    <match url="^docs(/.*)?" />
                    <action type="Rewrite" url="https://helloworld.document360.io/docs/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Next Step

Your documentation is live on your sub-folder now. But still the existing url for your project will serve the requests. For example - mycompany.document360.io and mycompany.com/docs (if /docs is your folder path) both will serve the documents.

It will cause duplicate content in Search Engines. To enable the redirect from mycompany.document360.io/docs/* to mycompany.com/docs/* - please contact us at support@document360.io.

Was This Article Helpful?