Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Web forwarding

Thread Tools
 
Search this Thread
 
Old Jun 2, 2004 | 03:44 PM
  #1  
IanWatson's Avatar
IanWatson
Thread Starter
Scooby Regular
 
Joined: Jul 2001
Posts: 504
Likes: 0
From: maturin23 - 205GTi Drivers.com
Default Web forwarding

Hi all,
I own both the .com and .co.uk domains for my website, and have up to now run parallel sites (it's static site at this point).

How do I automatically direct people who visit on the .uk domain to the .com site?

I'm sure this is stupidly easy, but all I found on Google were companies asking for money to do this.

cheers
ian
Reply
Old Jun 2, 2004 | 03:49 PM
  #2  
molko's Avatar
molko
Scooby Regular
 
Joined: Jun 2004
Posts: 638
Likes: 0
From: UK
Default

Here are just two simple ways to redirect your page!



1. This first example is useful if you want to inform your visitor that you have moved.

Into the HEAD section of your page type:


<meta http-equiv="refresh" content="5; URL=http://my new web address">


And into the BODY of your document put


"my old web address" has moved to "my new web address"

If your browser does not automatically redirect you in 5 seconds,
click <a href="http://my new web address">here</a> to go to the new site.



2. The second example using java script is handy if you have a number of domain names (for whatever reason) but want all names to point to the same domain.

Just add this to the top of your document:


<script language="JavaScript">
<!--
if( -1 == location.href.
toLowerCase().
indexOf('mydomainA.com') )
{
location.href = 'http://mydomainA.com';
}
// -->
</script>


The above code will check if 'mydomainA.com' is part of the code and if not will immediately redirect to 'http://mydomainA.com'

Option 2 is best I think unless you want to actually inform your visitor of the change then option 1 can be a good idea.
Reply
Old Jun 2, 2004 | 04:13 PM
  #3  
IanWatson's Avatar
IanWatson
Thread Starter
Scooby Regular
 
Joined: Jul 2001
Posts: 504
Likes: 0
From: maturin23 - 205GTi Drivers.com
Default

Thanks matey - will give it a go!
Reply
Old Jun 2, 2004 | 04:18 PM
  #4  
Wurzel's Avatar
Wurzel
Scooby Senior
iTrader: (1)
 
Joined: Nov 2000
Posts: 9,708
Likes: 73
From: Wildberg, Germany/Reading, UK
Default

If your using apache you can add this line to your httpd.conf file.

Redirect permanent /path from server root http://new url

ie

Redirect permanent /www/htdocs http://www.blah.com

do not use the full path from root as it won't work just go from your serverroot.
Reply
Old Jun 2, 2004 | 04:26 PM
  #5  
Wurzel's Avatar
Wurzel
Scooby Senior
iTrader: (1)
 
Joined: Nov 2000
Posts: 9,708
Likes: 73
From: Wildberg, Germany/Reading, UK
Default

stick this php script in your document root and call it index.php

<?php
/************************************************** ******************
* Dies ist ein PHP Script, das zur Weiterleitung von verschiedener *
* Domains auf verschiedene Ziele gebraucht wird. In dem Hash $parse *
* können beliebig viele Domainnamen angegeben werden und mit "=>" *
* getrennt, dahinter ihre Ziele. So wird "domain2.de" auf *
* ordner2/index.htm weitergeleitet. Die Default_Url diehnt dazu *
* Domains abzufangen die nicht im Hash vorkommen. *
* *
* Damit das Script arbeitet muss es im htdocs Verzeichnis liegen *
* Last Update 2003-07-29 10:23 *
************************************************** ******************/

$parse = parse_ini_file( "config.txt" );

$default_url = "index.html";

$http_host = $_SERVER[HTTP_HOST];
$http_host = preg_replace( "/www\./", "", $http_host );

if( $url = $parse[$http_host] ) {
$lines = file( "$url" );
foreach ($lines as $line_num => $line) {
//echo "$line_num: $line<br>";
if( preg_match( "/\<title\>(.*)\<\/title\>/", $line, $title )) {
break;
}
}
?>
<title><? echo $title[1]; ?></title>
<frameset>
<frame name='mainframe' src='<? echo $url; ?>'>
</frameset>
<?
}
else {
header("Location: $default_url");
}
?>


Then create a file called config.txt

to have 2 domain names pointing to the same website past this in it

yourdomain.com = a directory/index.html
yourdomain.co.uk = same directory/index.html

or you can use this to have seperate websites on seperate domain name on the same webspace just change the directory for the 2 domain names.

ie

yourdomain.com = cars/index.html
yourdomain.co.uk = bikes/index.html

then create the 2 directories in your document root

cars
bikes

or whatever you want them to be called in order to seperate your websites.

Last edited by Wurzel; Mar 8, 2006 at 09:29 AM.
Reply
Old Jun 2, 2004 | 05:48 PM
  #6  
sti555's Avatar
sti555
Scooby Regular
 
Joined: Dec 2003
Posts: 1,180
Likes: 0
From: cheshire
Default

Or use this one just pop your taget url in



<html>

<head>
<title>Redirection </title>
<noscript>
<meta http-equiv="refresh" content="2; URL=redirectiontarget.htm">
</noscript>
<script language="JavaScript">
<!--
var sTargetURL = "http://www.YourURLHere.com";

function doRedirect()
{
setTimeout( "window.location.href = sTargetURL", 2*1000 );
}

//-->
</script>

<script language="JavaScript1.1">
<!--
function doRedirect()
{
window.location.replace( sTargetURL );
}

doRedirect();

//-->
</script>

</head>

<body onload="doRedirect()">

<p>Loading <a href="redirectiontarget.htm">www.Your URL.com</a></p>
<p>In approx. 2 seconds the redirection target page should load.<br>
If it doesn't please select the link above.</p>

</body>

</html>
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Rbon91
ScoobyNet General
49
Nov 21, 2018 03:23 PM
Frizzle-Dee
Essex Subaru Owners Club
13
Dec 1, 2015 09:37 AM
bluebullet29
General Technical
9
Oct 5, 2015 02:17 PM
south_scoob
ScoobyNet General
22
Oct 3, 2015 01:05 PM
JackClark
Computer & Technology Related
18
Sep 30, 2015 02:00 PM




All times are GMT +1. The time now is 08:48 AM.