/    Sign up×
Community /Pin to ProfileBookmark

Domain Script

[CODE]<SCRIPT TYPE=”text/javascript”>

<!–

if (parent.location.href == self.location.href) {

if (window.location.replace)

window.location.replace(‘http://www.thedandygroup.com’);

else

// causes problems with back button, but works

window.location.href = ‘http://www.thedandygroup.com’;

}

// –>

</SCRIPT>[/CODE]

Someone gave me this script which is sapposed to make it so when I go to www.thedandygroup.com in my browser it will make it stay as www.thedandygroup.com instead of changing it to www.host123.com/sites/mysite/mypage.html like it is doing now. The only problem is that it has a few bugs like “causes problems with back button, but works” and I also needed it in php so this will work for all users to my site and not just people with javascript enabled. Can someone please help me fix the bugs in it and convert it to php. I would greatly appreciate it. I cannot ask the guy who gave it to me because he does not know php. Thanks for any help. ?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@pyroSep 06.2003 — Look into [URL=http://us2.php.net/manual/en/function.header.php]header()[/URL] to redirect the page and use something like $_SERVER['PHP_SELF'] (http://us2.php.net/manual/en/reserved.variables.php) to get the current page...
Copy linkTweet thisAlerts:
@JickauthorSep 06.2003 — I found this on the header link you gave me:[code=php]<?php
header("Location: http://".$_SERVER['HTTP_HOST']
.dirname($_SERVER['PHP_SELF'])
."/".$relative_url);
?>
[/code]
Is this the correct code or close to it?
Copy linkTweet thisAlerts:
@JickauthorSep 07.2003 — Could anybody let me know if the code in my last post is what I need? Thank you. ?
Copy linkTweet thisAlerts:
@pyroSep 07.2003 — Looking at it again, I'm not sure I know entirely what you are trying to do, but I'm not sure you can do it with PHP either way, as it appears you want to compare the current page's location with the parent location. Anyway, this JavaScript should work for you (and not mess up the back button):

&lt;script type="text/javascript"&gt;
if (parent.location.href == self.location.href) {
window.location.replace('http://www.thedandygroup.com');
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@JickauthorSep 07.2003 — I have registered a domain which is www.thedandygroup.com and I have it so when you goto www.thedandygroup.com it forwards you to the host where my files are which is a way long address like www.host123.com/sites/mysite/mypage.html. I'm trying to make it so when you go to www.thedandygroup.com the address will stay as www.thedandygroup.com instead of changing to www.host123.com/sites/mysite/mypage.html like it is doing now!
Copy linkTweet thisAlerts:
@pyroSep 07.2003 — That is probably not a scripting issue, but rather something that is happening on the server... Most likely the way your hosting is set up.
×

Success!

Help @Jick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...