Forum

Need help with URL toolkit

JamesTheawesomeDude
3 July 2013, 06:11
I want to set up my website so that anytime a URL of the form somedomain.cu.cc/resources/file.ext (or even www.somedomain.cu.cc/resources/file.ext) is accessed, it would redirect to resources.somedomain.cu.cc/file.ext - for example:

http://jamestheawesomedude.cu.cc/resources/bootstrap/css/bootstrap.min.css
gets redirected to:
http://resources.jamestheawesomedude.cu.cc/bootstrap/css/bootstrap.min.css

http://www.reismphack.cu.cc/resources/[1.5.2]ReiMinimap_v3.3_06[PATCH].zip
gets redirected to:
http://resources.reismphack.cu.cc/[1.5.2]ReiMinimap_v3.3_06[PATCH].zip

..et cetera. I couldn't figure out how to pull this off, perhaps somone else will have better luck?

Thanks in advance.

Hiawatha version: 9.1
Operating System: Debian GNU/Linux 7
Hugo Leisink
3 July 2013, 08:34
You can use the UrlToolkit to rewrite the URL.
VirtualHost {
...
UseToolkit = my_rewrite_rule
}

UrlToolkit {
ToolkitID = my_rewrite_rule
Match ^/resources/(.*) Rewrite /$1
}
JamesTheawesomeDude
3 July 2013, 15:28
That doesn't seem to be working...
Here is a sample piece of my hiawatha.conf file:
UrlToolkit {
ToolkitID = resources
Match ^/resources/(.*) Rewrite /$1
}VirtualHost {
Hostname = jamestheawesomedude.cu.cc
WebsiteRoot = /var/www
StartFile = index.html
ExecuteCGI = yes
TimeForCGI = 4
# UseToolkit = resources
}

VirtualHost {
Hostname = resourcesjamestheawesomedude.cu.cc
WebsiteRoot = /var/www/resources
ExecuteCGI = no
}


When I try to go to jamestheawesomedude.cu.cc/resources/bootstrap/css/bootstrap.css, it works fine, but if I uncomment the UseToolkit line, restart the serwer, and reload the page, it gives a 404 (but the URL never gets changed.) I recomment the line, restart the server, reload the page, and the file's there again.
Hugo Leisink
3 July 2013, 17:33
Ow, wait. The hostname is different. In that case:
UrlToolkit {
ToolkitID = resources
Match ^/resources/(.*) Redirect http://resources.jamestheawesomedude.cu.cc/$1
}
This topic has been closed.