How to Configure h5ai on WordPress (File Indexer)

If you have a website that provides downloads of pdfs, document files, zip files etc. then you can host the files on your own WordPress site using h5ai.

The advantage of hosting the files on your own website is to gain backlinks.

When people link to the files hosted by your site, you gain backlinks from them.

Before Configuring h5ai

h5ai requires PHP 7.0+ and works with Apache httpd, lighttpd and Nginx web servers.

If you have have subscribed to a manged hosting from a third party hosting service provider like BlueHost or Cloudways etc. then they are already using either httpd (Apache) or Nginx.

WordPress itself runs on PHP so that should already be there, but these are the requirements to keep in mind if you have a self hosted WordPress site like mine.

Download h5ai

First you need to download and extract the h5ai which is available in .zip file package.

Visit the below link to download the same:
h5ai Builds

[sc_note note_color=”#FBF4DD” text_color=”#A38C68″ radius=”3″ class=”” id=””]You must download the zip package file on the server you want to configure. Follow one of the below procedure to get this done.[/sc_note]

Direct Download on the WordPress Server

If you have access to a command window, you can use the wget command to download the above build.

If wget is not installed, first install the wget command and then execute the below command to download h5ai:


Upload to the WordPress Server

If you do not have access to a command window on your server then, you can just download the latest h5ai package from the above link and upload that file to your server.

Make sure you upload the zip file on the directory under WordPess where you want to host downloadable files.

For example:
If you WordPress directory on the server is as below:

And you want to make the as the download directory, then create a downloads directory as below:

The h5ai*.zip file must be kept under /var/www/ directory.

Extract and Test h5ai:

Once you have downloaded the above build, you need to extract the package and then test it.

Using the command line (or a web interface) go to the /var/www/ directory and execute the below command to extract the files:

[sc_note note_color=”#FBF4DD” text_color=”#A38C68″ radius=”3″ class=”” id=””]If you do not have the unzip command then install that and then execute the above command.[/sc_note]

Once extracted, visit the below url on a web broser to see if this is accessible or not:

You should be able to see the below screen, if everything is OK.

h5ai direct index.php access

Even after this, the download url should be forbidden.

h5ai forbidden on WordPress

We have not yet configured the Apache or Nginx server yet to allow access to this directory. While accessing this directory, WordPress’ index.php comes in and returns 404 error.

So, in the next step I will show you how to configure Apache httpd and Nginx to allow h5ai to show underlying files under the desired /downloads/ url (you might have chosen a different name).

Configure h5ai to Allow Access Under WordPress

Just installing h5ai will not show the files lying inside the respective directory.

You need to configure the web server to tell that when this particular directory is accessed, pass the control to h5ai’s index.php (and do not process WordPress index.php).

Configuring h5ai on Apache httpd:

If you do not have access to the server’s config files then you can create a .htaccess file under the /downloads/ directory and add the following line:

DirectoryIndex  index.html  index.php  /downloads/_h5ai/public/index.php

If you have direct access to the server, you can directly edit the .conf file on your server for this domain and add the below code inside the entry:

<directorymatch "/downloads/">
       DirectoryIndex  index.html  index.php  /downloads/_h5ai/public/index.php
       Require all granted

Once done, restart the apache server by executing the below command and your done.

sudo systemctl restart httpd

Configuring h5ai on Nginx:

If you have a WordPress site running on Nginx server then you can enable h5ai by adding the below code on your site’s .conf file:

location /downloads/ {
        try_files $uri /downloads/_h5ai/public/index.php;

Once done, restart the apache server by executing the below command and your done.

sudo systemctl restart nginx

Once restarted the server, now access the downloads directory and you should be able to see the files inside:

h5ai access under WordPress

Just copy any files or folders under the /downloads directory and it should immediately reflect under the respective url.
Considering cache in place, you may need to flush the cache to read the changes immediately.

That’s all on configuring h5ai on WordPress.

If you find any difficulties or error while setting up this thing, you can leave a comment so that I can look into the issue.

Make sure you leave the configuration you changed etc. so that I can help you as early as possible.

Leave a Comment