Hay men, I am getting a little of the problem.

Say i've the domain www.foo.com, but this domain is presented-submitted to www.bar.com.

world wide web.foo.com continues to be within the address bar, however i now have to redirect www.foo.com to www.bar.com. Then when you hit foo.com, you receive rerouted to close.org.

I attempted carrying this out in PHP, however it appears that the $_SERVER variables are in accordance with bar.com (due to the presented sending). I additionally attempted to obtain the URL using javascript, however this unsuccessful.

How could i redirect www.foo.com to www.bar.com?

Oh, and that i don't have the domain, i have only FTP.

The server is apache, and that i get access to PHP.

Most significant factor I didn't remember to inform:

I do not get access to www.foo.com.

You ought to be delivering a header 301 using PHP. You could include the next code towards the file index.php within the domain www.bar.com.

if(strpos($_SERVER['HTTP_HOST'], 'foo.com') !== false)
{
    header ('HTTP/1.1 301 Moved Permanently');
    header ('Location: http://www.bar.com/');
}

You could utilize htaccess.

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.bar.com/$1 [R=301,L]

Save this inside a file known as .htaccess and put it within the cause of www.foo.com

There is a couple of options: Apache mod_alias, or PHP header miracle, as proven by Michiel Pater.

mod_alias:

 Redirect / http://www.bar.com/

then, the only real solution open to you is javascript-based one

most typical strategy is

<SCRIPT LANGUAGE="JavaScript">
<!--

if (window != top) top.location.href = location.href;

// -->
</SCRIPT>