rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: warloc on September 13, 2021, 08:16:28 AM

Title: Two folders, two websites?
Post by: warloc on September 13, 2021, 08:16:28 AM
If I have two different URLs pointing at my IP, is there a way to get HFS to differentiate, and direct the different URLs to different folders?
Title: Re: Two folders, two websites?
Post by: vladimirov70 on September 13, 2021, 06:13:30 PM
If URL is a domain name, then you can try URL redirecting at your domain name registrar. Perhaps.
(http://images.vfl.ru/ii/1631556561/179ab78e/35852537_s.jpg) (http://vfl.ru/fotos/179ab78e35852537.html)
Title: Re: Two folders, two websites?
Post by: warloc on September 13, 2021, 07:30:22 PM
I'm not sure registrars can point at specific folders?

I'll definitely check.
Title: Re: Two folders, two websites?
Post by: warloc on September 14, 2021, 02:26:11 AM
No, that doesn't work, they can only point at IPs, not subfolders within those IPs.

HFS really has no way to do it?
Title: Re: Two folders, two websites?
Post by: dj on September 14, 2021, 08:13:15 AM
try something like this
Properties - Diff template

Code: [Select]
[+]
<script>
if (location.href=='http://192.168.137.1/') location.href+='/Folder1'; else console.log('todo')
</script>


Title: Re: Two folders, two websites?
Post by: LeoNeeson on September 14, 2021, 08:25:25 AM
Hi!, I'm 99.9% sure HFS is able to handle this situation, using 'HFS.events' and some macros. I did my best searching all the forum, but I could not find whether this was already discussed or not.

I will try to help you, giving a proof-of-concept idea. For example, lets say you have 'example1.dynDNS.com' and 'example2.dynDNS.com', and Folder1 and Folder2.

1) Switch to 'expert mode', pressing F5 inside HFS window.
2) Go to: Menu > IP Address > Custom... and add your domains.
3) At HFS window, press Alt+F6 to edit the 'hfs.events' file, and put the following text:

Code: [Select]
[+request]
{.if|{.match address|example1.dynDNS.com|%host%.}|
{.add header|location: /Folder1.}|
{.if|{.match address|example2.dynDNS.com|%host%.}|
{.add header|location: /Folder2.}|
{:{.disconnect.}:}
./if}

WARNING: The contents of that "hfs.events" were NOT tested by me, and that code may not work at all! (I'm just giving an idea on how it could work). That's all I can help you (my knowledge about macros is limited). I hope someone else (expert on macros), could give you a hand (meanwhile, you can read the HFS's Wiki here (http://www.rejetto.com/wiki/)). / Edit: I was writing this before 'dj' posted.

Cheers,
Leo.-
Title: Re: Two folders, two websites?
Post by: Rapid on September 14, 2021, 01:37:02 PM
I would recommend to use reverse-proxy for this.
For example nginx.
It can handle any domains, folders, etc...