Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I enable one website URL to 're-direct' to another URL

Status
Not open for further replies.

MHUK

Programmer
Nov 30, 2002
139
GB
Hi

I have a question about how to 're-direct' from one website to another, so the two URL's effectively have the same website content.

Is this at all feasible? So say I had one website with a standard URL like 'carinfo.com'. And I decide to set up an alternative domains called autoinfo.com. Is there a line of code that would enable the user who clicks autoinfo.com to be re-directed to my standard URL: carinfo.com? So effectively autoinfo.com would have the same website content as carinfo.com.

Please can anyone say if this is feasible, and what code I could write to implement this.

Thank you very much for any help.

MHUK



 
There's many ways to do it!
here's a few ideas:

1. Your register and probably webhost could point one url to another site

2. you could use meta refresh:
<meta http-equiv=&quot;refresh&quot; content=&quot;0; URL=http://my_new_web_address&quot;>

3. You could use javascript:
<script language=&quot;JavaScript&quot;>
<!--
if( -1 == location.href.
toLowerCase().
indexOf('your-domain.fi') )
{
location.href = '}
// -->
</script>

4. You could use php
header( 'Location: );


5. you could use frames and have the content from 1 url showing under the other url, personally I hate frames

6. you could use SSI to redirect OR to include the content from 1 page into the content from the other page.

Hope that gives you a few ideas


É ::
 
Thank you for your info. Really appreciated. Is it possible to have more than one website redirect to the same website?

I am more than likely going to use the PHP option for re-direction as most of my coding is in PHP. 'Location:
Please can you tell me where I would write the above line of code, would it be in the default/index page of my website? And in your example above, would ' represent my normal standard URL that I want to redirect to, or the would it represent the alternative URL?

For having more than one alternative URL would I simply write this line of code for each alternative domain?


One other question, how is it possible to enable users to be sent to when they only write 'mydomain.com' without the ' I notice with some websites you can simply write the domain name without the 'www' but with others you will be sent to an 'auto.msn' page saying the website cannot be found. Please can you tell me if there is a line of code to enable a user to be sent to the website even if they do not include the '

Thank you very much for any help with this.
 
You can have as many websites as you want pointing to any particular address.

I'm not a PHP'er so I'm not sure if this is right but to redirect with php just put the following into the index page of the site you want to redirect
<?
Header('Location: ?>

here domain.com is the URL you want to go TO.

If you have many alternate URLs, each one could have the above code in their index page and will all be redirected to domain.com

As for leaving out the www. I think your webhost can arrange that. I think represents the public sub-domain of your site, different hosts set up their accounts differently.


É ::
 
Ok thanks for your help. I'll try all of that.

Much appreciated.
MHUK
 
If you're interested in saving money, your best redirect option IMO is the
<meta http-equiv=&quot;refresh&quot; content=&quot;0; URL=http://my_new_web_address&quot;>;

Option... that way you can put your real web site on a full fledged host where you're paying for PHP and whatnot, and all the others on the cheapest plan which offers little bandwidth and no PHP support and no frills.... of course if they'll package them all together for you then it's a moot point.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top