tell which domain the user is accessing?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Wilson

    tell which domain the user is accessing?

    Hi,

    I've got a site which Google is indexing 3 different ways:
    glassgiant.com
    host5.veoweb.ne t/~glassgia
    veodns.com/glassgia

    I only want people accessing it the first way. If they access it any
    way but through the domain, I would like to send a moved permanently
    code, or at least use a header("Locatio n: blah blah blah").
    Unfortunately, I can't figure out how to detect anything before the
    first slash in the URL. Any suggestions?

    Thanks,
    Shawn

    --
    Shawn Wilson
    shawn@glassgian t.com



  • Justin Koivisto

    #2
    Re: tell which domain the user is accessing?

    Shawn Wilson wrote:
    [color=blue]
    > Hi,
    >
    > I've got a site which Google is indexing 3 different ways:
    > glassgiant.com
    > host5.veoweb.ne t/~glassgia
    > veodns.com/glassgia
    >
    > I only want people accessing it the first way. If they access it any
    > way but through the domain, I would like to send a moved permanently
    > code, or at least use a header("Locatio n: blah blah blah").
    > Unfortunately, I can't figure out how to detect anything before the
    > first slash in the URL. Any suggestions?[/color]

    If you have access to mod_rewrite on your server, create a .htacccess
    file with the following:

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.glassgian t\.com [NC]
    RewriteRule ^/~glassgia(.*) http://www.glassgiant. com$1 [R=301]

    RewriteCond %{HTTP_HOST} ^www.veodns.com [NC]
    RewriteRule ^/glassgia(.*) http://www.glassgiant. com$1 [R=301]

    This would send a status code of 301 (moved permanently), and redirect
    the request.

    HTH

    --
    Justin Koivisto - spam@koivi.com
    PHP POSTERS: Please use comp.lang.php for PHP related questions,
    alt.php* groups are not recommended.

    Comment

    • sam

      #3
      Re: tell which domain the user is accessing?

      <?php

      // the name of the host => http://$host_name/bla/bla/index.php
      $host_name = $_SERVER['HTTP_HOST'];

      // if we don't find glassgiant.com in the host_name, we redirect
      if(!ereg("glass giant.com",$hos t_name))
      header("Locatio n: http://glassgiant.com" );
      ?>


      Shawn Wilson <shawn@glassgia nt.com> wrote in message news:<3F046004. D0D007D6@glassg iant.com>...[color=blue]
      > Hi,
      >
      > I've got a site which Google is indexing 3 different ways:
      > glassgiant.com
      > host5.veoweb.ne t/~glassgia
      > veodns.com/glassgia
      >
      > I only want people accessing it the first way. If they access it any
      > way but through the domain, I would like to send a moved permanently
      > code, or at least use a header("Locatio n: blah blah blah").
      > Unfortunately, I can't figure out how to detect anything before the
      > first slash in the URL. Any suggestions?
      >
      > Thanks,
      > Shawn[/color]

      Comment

      Working...