rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: D on March 23, 2022, 10:36:58 AM

Title: How can I set up a simple redirect?
Post by: D on March 23, 2022, 10:36:58 AM
www.example.com/123/321.jpg
should be redirected to
www.example.com/000/321.jpg
and same with all files in /123/

is this possible?
Title: Re: How can I set up a simple redirect?
Post by: NaitLee on March 23, 2022, 12:31:33 PM
In HFS main window, press Alt+F6 to open "event script", inside put this:
Code: [Select]
[download]
{.set|path|{.decodeuri|%url%.}.}
{.if|{.=|{.cut||4|{.^path.}.}|/123.}|{:{.redirect|/000{.cut|5||{.^path.}.}.}:}.}

Press Ctrl+S to save it.
With this users can view /123 but when they download something they will get from /000
This is explicit, users will see the redirection in address bar.

To edit this, let's say redirect /photo to /picture:
- change /123 to /photo
- change /000 to /picture
- change 4 to 6, i.e. the length of "/photo"
- change 5 to 7, i.e. length of "/photo" +1

Know more about macro "cut" at here (https://rejetto.com/wiki/index.php?title=HFS:_scripting_commands#Data_manipulation)

In case your folder name have non-ascii characters, be sure to save the event script in UTF-8 encode