Forum

rewrites problem

Sjir Bagmeijer
23 August 2015, 11:14
I am trying to convert all my old nginx rewrites to hiawatha but it seems I do something wrong because they all keep givng 404.

Currently in Nginx I have the following rewrites:
 rewrite ^/threads/ulyaoth-repositories.3/ https://www.ulyaoth.net/resources/ulyaoth-repository.6/;
rewrite ^/threads/package-ulyaoth-hiawatha.23037/ https://www.ulyaoth.net/resources/hiawatha.7/;
rewrite ^/threads/package-ulyaoth-mbedtls.12137/ https://www.ulyaoth.net/resources/mbed-tls.8/;
rewrite ^/threads/package-ulyaoth-monkey.11622/ https://www.ulyaoth.net/resources/monkey.9/;
rewrite ^/threads/package-ulyaoth-tengine.3843/ https://www.ulyaoth.net/resources/tengine-stable.10/;
rewrite ^/threads/package-ulyaoth-httpdiff-masterbuild.741/ https://www.ulyaoth.net/resources/httpdiff.11/;
rewrite ^/threads/package-ulyaoth-solr.112/ https://www.ulyaoth.net/resources/solr-5.12/;
rewrite ^/threads/package-ulyaoth-banana.111/ https://www.ulyaoth.net/resources/banana.13/;
rewrite ^/threads/package-spotify.6/ https://www.ulyaoth.net/resources/spotify.14/;


In Hiawatha I do the following,
UrlToolkit {
ToolkitID = xenforo
Match ^/threads/package-ulyaoth-hiawatha.23037/ Rewrite /resources/hiawatha.7/
Match ^/threads/package-ulyaoth-mbedtls.12137/ Rewrite /resources/mbed-tls.8/
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}


I also tried this:
UrlToolkit {
ToolkitID = xenforo
Match ^/threads/package-ulyaoth-hiawatha.23037/ Redirect https://www.ulyaoth.net/resources/hiawatha.7/
Match ^/threads/package-ulyaoth-mbedtls.12137/ Rewrite https://www.ulyaoth.net/resources/mbed-tls.8/
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}

But neither works it does not give an error I just get a 404 error when I try go to "/threads/package-ulyaoth-hiawatha.23037/".

Any idea what I do wrong perhaps?
Sjir Bagmeijer
5 September 2015, 12:26
Hugo do you have any idea what I do wrong perhaps? still stuck with this.

What I basically want is my old urls to redirect to the new version so:
https://www.ulyaoth.net/threads/package-ulyaoth-hiawatha.23037/ should become https://www.ulyaoth.net/resources/hiawatha.7/

Could you perhaps show me how to do this one?
Hugo Leisink
5 September 2015, 21:59
Sorry, I somehow must have missed this one.

I have no idea what's inside, for example, the /resources/hiawatha.7/ directory and what should be shown. Is there an index.php? Should a directory listing be shown?
Sjir Bagmeijer
6 September 2015, 08:29
I basically just want to match that url and rewrite or redirect it to the new url.

But the general rewrite to make the php app work I use is this:
UrlToolkit {
ToolkitID = xenforo
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}

The directories basically not exist it is just how they call it friendly urls.
Hugo Leisink
6 September 2015, 09:31
But when /threads/package-ulyaoth-hiawatha.23037 has been rewritten to /resources/hiawatha.7/, how is Hiawatha supposed to handle /resources/hiawatha.7/? Now, Hiawatha probably look for an index.php file in that directory. If it not exists, you end up with a 404.
Sjir Bagmeijer
6 September 2015, 10:01
Thank you for the reply it is supposed to process the new url/rewrite with this toolkit:

UrlToolkit {
ToolkitID = xenforo
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}

Sjir Bagmeijer
6 September 2015, 10:43
I resolved it started to think about what you said about what is it supposed to do so I tried some things and this works fine now:

UrlToolkit {
ToolkitID = xenforo
Match ^/threads/ulyaoth-repositories.3/ Redirect /resources/ulyaoth-repository.6/
Match ^/threads/package-ulyaoth-hiawatha.23037/ Redirect /resources/hiawatha.7/
Match ^/threads/package-ulyaoth-mbedtls.12137/ Redirect /resources/mbed-tls.8/
Match ^/threads/package-ulyaoth-monkey.11622/ Redirect /resources/monkey.9/
Match ^/threads/package-ulyaoth-tengine.3843/ Redirect /resources/tengine-stable.10/
Match ^/threads/package-ulyaoth-httpdiff-masterbuild.741/ Redirect /resources/httpdiff.11/
Match ^/forums/repository/ Redirect /resources/categories/repository.1/
Match ^/forums/guides/ Redirect /resources/categories/it-tutorials.2/
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}


Thank you again Hugo!
Sjir Bagmeijer
6 September 2015, 10:46
Perhaps you could add "Xenforo" on this page: https://www.hiawatha-webserver.org/howto/url_rewrite_rules

The correct rewrite is this:
UrlToolkit {
ToolkitID = xenforo
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}


Might help someone else.
Hugo Leisink
7 September 2015, 10:28
Good to hear it all works! I've added the rewrite rule to the HOWTO page. Thanks!
This topic has been closed.