View Full Version : Subfolder script
Silver
01-23-2005, 07:09 AM
Here is a small script, quite a bit out of the box. I made it, so that in domain redirects, when hello.xyz redirects to ur site, to go to a subfolder in ur site.
Folder redirect.
Consider that you have something like hello.xyz site registered to you. Well, its not really registered. Its sortof like a domain redirection service.
The following scripts makes you access subfolders from the domain. For eg, if you type hello.xyz/forum , it will automatically go to http://hostmatrix/users/whatever/myname/forum/
WARNING: It will not work on .tk domains, as the top frame is protected.
//Consider the site- http://hello.xyz/subfolder
<html><head><title>Detector</title>
<script>
function gotofol(){
var location=top.location.href; //If the frame is not protected, this should work.
var len=location.length-1;
var folder=top.location.href.substr(17,len);
top.location.href="http://hostmatrix.org/username/"+folder;
}
</script>
</head><body onload=gotofol()>
</body>
</html>
Excellent Script :) I'm sure people who use redirectors will be delighted to have a simple way of doing what you just explained.
Great Job,
Tim :)
shwaza
01-23-2005, 02:05 PM
Sorry, i'm kinda slow today, but what exactly will it do? Just, onload redirect to a certain directory in your account? Because couldnt you just do
<html>
<head>
</head>
<body onload="window.location.href='forums'">
Redirecting...
</body>
</html>
Because that's how i've always done redirects, or maybe i dont understand this...
Silver
01-23-2005, 02:22 PM
Consider, you host a site http://hostmatrix.org/mysite and have a domain redirect like mysite.wb.st
Now, when you go to http://mysite.wb.st , u will be redirected to http://hostmatrix.org/mysite . But if you go to http://mysite.wb.st/forum, you will still be redirected to http://hostmatrix.org/mysite (not /forum)
Putting that script on http://hostmatrix.org/mysite/index.html , you can enable that when u go to http://mysite.wb.st/forum , you will go to the forum subdirectory.
btw, also, you can just modify the script a little. In the earlier example, I didnt make it as userfriendly as it could be. Nyways, here is it.
//Consider the site- http://hello.xyz/subfolder
<html><head><title>Detector</title>
<script>
function gotofol(realurl,virturl){
var folder=top.location.href.substr(virurl.length,top. location.href.length);
top.location.href=realurl+folder;
}
</script>
</head><body onload=gotofol("http://hostmatrix.org/mysite/","http://www.hello.xyz/")>
<!--- All you haveto do is edit the above line. The first parameter being passed is ur actual url, and the second is the url of the redirection. ONly the base url. DO NOT forget the trailing '/' --->
</body>
</html>
Just change what needs to be changed.
Also, btw, I made a slight error in the earlier script, if you still wish to use it. The correct script of the earlier one is-
//Consider the site- http://hello.xyz/subfolder
<html><head><title>Detector</title>
<script>
function gotofol(){
var location=top.location.href; //If the frame is not protected, this should work.
var len=location.length;
var folder=top.location.href.substr(18,len);
top.location.href="http://hostmatrix.org/username/"+folder;
}
</script>
</head><body onload=gotofol()>
</body>
</html>
Just lost it when counting the word. heh :$
shwaza
01-23-2005, 03:49 PM
Ohh, ok i get it now :), actually though i find most redirect services such as the one mck loves so much :P .us.tt if you go to shwaza.ca.tt/forums it will already go there by default, but maybe that would work niceley on a different one :)
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.