Archive for myfreeforum.org Before posting please check the "stickies" in the support forums.
Please ask questions in real English and not "txt". You will get a better response.
Please do not ask support questions via PMs.
 



       myfreeforum.org Forum Index -> PhpBB3 General Support
Zudane

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.
admin (no pm's please)

window.location

is probably the variable to test.
Zudane

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?
admin (no pm's please)

bad code mate "=" is an assignment ! not a test.

hence you get the result you thing you are testing for!
admin (no pm's please)

==

is the test operator.
Zudane

*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.
admin (no pm's please)

debugging is your friend. Does :

Code:

alert(window.location);


give you "http://address" or just the address?

Can't recall at the second.
Zudane

gives the full http://zudane.myfastforum.org
admin (no pm's please)

does your code get to inside the if statement?
admin (no pm's please)

its an old chesttnut use code here:

http://grizzlyweb.com/webmaster/javascripts/redirection.asp


window.location will be overridden when the page loads, so your replace will be replaced   you need to use a timeout.
Zudane

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
admin (no pm's please)

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.
Zudane

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....
Zudane

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.

       myfreeforum.org Forum Index -> PhpBB3 General Support
Page 1 of 1
Create your own free forum | Buy a domain to use with your forum