Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Sun Jun 22, 2008 1:36 am Post subject: Redirect question |
|
|
I did a search, and didn't find anything relevant for this...
I am sure there is a way, but I'm not certain how (I'm a bit rusty on javascript/html... okay more than a bit, it's been a while).
What I am looking for, is something I can add into the header that would check if it is the MFF address (nothing against it, but I want to be using my own), and if so redirect it to my own.
Something similar to (but much more complicated than)
if url = *zudane.myfastforum.org*
then redirect = http://harsh-reality.info/index.php
I know it can be done, but I'm not sure if it can from the access I am given. And otherwise, I wouldn't even remember how. A confirmation and code for this would be useful.
_________________
Harsh Reality - A community forum
http://Harsh-reality.info |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 5:54 am Post subject: |
|
|
Any suggestions about this?
I tried something along the lines of (I forget the exact)..
| Code: |
if (window.location="http://zudane.myfastforum.org")
{
window.location.replace('http://harsh-reality.info')
}
|
But apparently the old URL is still active for the same site, even with the new domain name used, so this just gets caught in an infinite redirect loop.
Any ideas? _________________
Harsh Reality - A community forum
http://Harsh-reality.info |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 5:14 pm Post subject: |
|
|
*kicks his brain*
I don't think it wants to work... I know that I know what the problem is, but I just can't see it. I am way too rusty on this
| Code: | <script type="text/javascript">
if (window.location=="http://zudane.myfastforum.org")
{
window.location.replace('http://google.com');
}
</script> |
I set it to google just to test it, make it more obvious if it works, for my tired brain.
When I had it set to just = then it would redirect no matter what, now that it's set at == it won't redirect at all.
I know the error is obvious, but like I said, my brain died. _________________
Harsh Reality - A community forum
http://Harsh-reality.info |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 5:17 pm Post subject: |
|
|
debugging is your friend. Does :
| Code: |
alert(window.location);
|
give you "http://address" or just the address?
Can't recall at the second. _________________
Family Friendly Shareware | | Web Design/Services | Free Forums
forum.myfreeforum.org |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 5:58 pm Post subject: |
|
|
Still doesn't quite solve it. I still need to get the if conditional to make it so it only refreshes from the mff page instead of throwing it into an infinite redirect.
I looked for another, but still can't get it right...
Just tried two codes that set the window.location as a variable and then compare it against the one I am looking for... but I think the problem is that checking the window.location against it might be looking for say.. http://zudane.myfastforum.org/http://zudane.myfastforum.org and since that isn't true, it's being skipped... I could be wrong. I can't remember how to debug it right now, still tired from work and rusty on this, and the two are a bad mix _________________
Harsh Reality - A community forum
http://Harsh-reality.info |
|
| Back to top |
|
 |
admin (no pm's please) Site Admin

 Virtual Cash: 42950
Joined: 22 May 2005 Posts: 19352
Add Karma
 rated by 157 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 6:03 pm Post subject: |
|
|
I can't see a timeout, just some iffy comparison tests.
I'd be using location.substring(...)="http://zudnane..." but you do have to look at javascript string functions for the right syntax and make use of alert and the error console. _________________
Family Friendly Shareware | | Web Design/Services | Free Forums
forum.myfreeforum.org |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 6:18 pm Post subject: |
|
|
I tried it the other way around.. now, if it's loading from harsh-reality.info, it does something useless... since I can't think of the break command for it (I think taking a straight java class messed me up... I'm so mixed up in my what-commands-work-with-what-coding right now)
But, now it works right, if it loads from any page besides harsh-reality.info, it loads harsh-reality.info.
I'll post the code so it answers any other questions...
| Code: | | Edited out code so it won't confuse people |
Getting it to match was too hard, so I thought of it backwards.. how about if it doesn't match, lets make it! Can't fit the square peg into the round hole? make the peg round!
---
edit
He He cancel that, now all links lead back to the main page.... _________________
Harsh Reality - A community forum
Last edited by Zudane on Tue Jun 24, 2008 6:38 pm; edited 1 time in total
http://Harsh-reality.info |
|
| Back to top |
|
 |
Zudane Apprentice

Virtual Cash: 1760
Joined: 10 May 2008 Posts: 173
Add Karma
 rated by 3 members
Add Comment
Show Comments
 |
Posted: Tue Jun 24, 2008 6:32 pm Post subject: |
|
|
Okay, this time I actually tested it first
| Code: |
<script language="Javascript">
var origin=window.location;
if
((origin == "http://zudane.myfastforum.org/") || (origin == "http://zudane.myfastforum.org/index.php"))
window.location.replace('http://harsh-reality.info/');
</script> |
Javascript is apparently quite picky when you leave off the / at the end. http://zudane.myfastforum didn't work, but http://zudane.myfastforum.org/ did. I also added the or for if it loads from the index page, to redirect to the new address.
For anybody else to use it...
| Code: |
<script language="Javascript">
var origin=window.location;
if
((origin == "Old Site name with / at end") || (origin == "Second option for site name IE: index.php"))
window.location.replace('new url');
</script> |
^_^
Thanks for working with me admin. I'm going to make sure to add in a link to the site here. By far the best support I've gotten ^_^
Edit: Changed href to replace. location.href will direct to the new page, but the user can still hit the back button and get re-redirected. replace will replace it in the history so when the user hits back, they go to the page they were at before they hit yours. _________________
Harsh Reality - A community forum
http://Harsh-reality.info |
|
| Back to top |
|
 |