myfreeforum.org Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  Who is OnlineWho is Online   Join! (free) Join! (free)  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
For an excellent guide to using your myfreeforum forum, you can visit
howtodoit
The howtodoit "readonly" forum provides answers and walkthroughs for all common questions.
  • Welcome
  • Guest


Redirect question

 
Post new topic   Reply to topic    myfreeforum.org Forum Index -> PhpBB3 General Support
View previous topic :: View next topic  
Author Message
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Sun Jun 22, 2008 1:36 am    Post subject: Redirect question Reply with quote

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
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Sun Jun 22, 2008 1:49 am    Post subject: Reply with quote

window.location

is probably the variable to test.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:54 am    Post subject: Reply with quote

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
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 9:02 am    Post subject: Reply with quote

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

hence you get the result you thing you are testing for!
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 9:51 am    Post subject: Reply with quote

==

is the test operator.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:14 pm    Post subject: Reply with quote

*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
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:17 pm    Post subject: Reply with quote

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
View user's profile Private message Send e-mail Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:19 pm    Post subject: Reply with quote

gives the full http://zudane.myfastforum.org
_________________


Harsh Reality - A community forum

http://Harsh-reality.info
Back to top
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:23 pm    Post subject: Reply with quote

does your code get to inside the if statement?
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:25 pm    Post subject: Reply with quote

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

Family Friendly Shareware | | Web Design/Services | Free Forums

forum.myfreeforum.org
Back to top
View user's profile Private message Send e-mail Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 5:58 pm    Post subject: Reply with quote

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
View user's profile Private message Visit poster's website
admin (no pm's please)
Site Admin
Site Admin

Virtual Cash: 42950

Joined: 22 May 2005
Posts: 19352

Add Karma

rated by 157 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 6:03 pm    Post subject: Reply with quote

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
View user's profile Private message Send e-mail Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 6:18 pm    Post subject: Reply with quote

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
View user's profile Private message Visit poster's website
Zudane
Apprentice
Apprentice

Virtual Cash: 1760

Joined: 10 May 2008
Posts: 173

Add Karma

rated by 3 members
Add Comment
Show Comments

online/offline
PostPosted: Tue Jun 24, 2008 6:32 pm    Post subject: Reply with quote

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
View user's profile Private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    myfreeforum.org Forum Index -> PhpBB3 General Support All times are GMT + 1 Hour
Page 1 of 1
 
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Create your own free forum | Buy a domain to use with your forum