Forum

UrlToolkit applied per directory

Erik S
27 April 2017, 16:51
Hello Hugo, I am looking for a way to use url rewrite in a toolkit in sub-directories. Web root is/var/www/hiawatha, ZoneMinder is in /usr/share/zoneminder/www which is aliased to /zm. I need to be able to rewrite urls when the ZM API is being polled. The Toolkits you have translated work and rewrite to the correct URL when I compare them to the results of the Apache rewrite, tested using wigwam -t. The problem is the .htaccess files that do these rewrites are in /usr/share/zoneminder/www/api and /usr/share/zoneminder/www/api/app, that are aliased as http://localhost/zm/api or http://localhost/zm/api/app....how can I simulate this with Hiawatha? I can not use .hiawatha files with the line UseToolkit = api_second_rule in anything other then the website root without causing internal server errors. An API call would look like http://server/zm/api/host/getVersion.json. I am hoping you may have some ideas on how to achieve this.
Hugo Leisink
27 April 2017, 19:25
I don't know this ZoneMinder and I'm a bit confused by all the required rewrites and aliases. A request to http://localhost/zm/api/host/getVersion.json should end up at /usr/share/zoneminder/www/api/host/getVersion.json, right? I don't see any mentioning of 'webroot', so no rewriting is required. Than all you need is the alias, I think.
Erik S
27 April 2017, 22:02
zoneminder is an open source camera security system and network video recorder, it can control and monitor motion detection across hundreds of cameras if setup that way. Basicly this url works /localhost/zm and this one /localhost/zm/api will not. The API is constructed with cakePHP and does REST. The REST API is built with cakePHP the rest of the ZM web console is not. For cakePHP to work I think involves rewrite for it to work in Hiawatha. My problem is only the sub directory /zm/api is cakePHP and only this directory needs a rewrite...which is done with a htaccess file. How can I apply the Toolkit rules to a sub directory of the web root and not the web root?
Hugo Leisink
27 April 2017, 22:50
If only URIs starting with /zm/api need rewriting, simply make the URI after Match in the UrlToolkit rule start with /zm/api.
Erik S
28 April 2017, 07:00
Thank you so much! I now have solved the API rewrites , after your suggestion I realized I was making it over complicated. Now I have a complete install of ZoneMinder running with all features and functions working under a Hiawatha server. Here is the URLToolkit that will allow the ZoneMinder API to work:
UrlToolkit {
ToolkitID = api_rule
Match ^/zm/api Rewrite /zm/api/app/webroot/index.php$1
}
This topic has been closed.