1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirecting www to non-www (and vice vursa) on Apache and IIS

Discussion in 'Apache' started by SEbasic, Jun 13, 2005.

  1. #1
    Anyone got any info on redirecting from www.DOMAIN.com to DOMAIN.com (without the www)

    I need info for both IIS and Apache.
    This is kinda desperate as I have a whole bunch of sites I fear could be smaked with a dupo content penalty...
     
    SEbasic, Jun 13, 2005 IP
  2. mariense

    mariense Well-Known Member

    Messages:
    104
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #2
    If you have isapi_rewrite on your Windows server, this will work (add it to the httpd.ini file):

    RewriteCond Host: ^example\.com
    RewriteRule (.*) http\://www\.example\.com$1 [I,RP]

    This will 301 redirect http://example.com to http://www.example.com
     
    mariense, Jun 13, 2005 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    digitalpoint, Jun 13, 2005 IP
  4. ro_core

    ro_core Peon

    Messages:
    6
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Removing the www for your domain
    http://wiki.dreamhost.com/index.php/Removing_the_%22www%22_from_your_domain

    Requiring www for your domain
    http://wiki.dreamhost.com/index.php/Requiring_%22www%22_for_your_web_site

    From dreamhost's wiki; doesn't only apply to dreamhost, and is well explained.
     
    ro_core, Jun 13, 2005 IP
  5. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you very much guys!

    Is isapi_rewrite goign to have to be there to do anything like that on IIS (This is for client sites too and I'm no sure what they have installed on all of their servers - They'res a few)...
     
    SEbasic, Jun 13, 2005 IP
  6. ziandra

    ziandra Well-Known Member

    Messages:
    142
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    138
    #6
    The EASY way in apache is in the virtual host section of your apache configuration file. E.G. my httpd.conf contains:

    
    <VirtualHost *>
    ServerAdmin ziandra@ziandra.net
    ServerName ziandra.net
    Redirect / http://www.ziandra.net/
    </VirtualHost>
    
    <VirtualHost *>
    ServerAdmin ziandra@ziandra.net
    ServerName www.ziandra.net
    DocumentRoot /home/www/ziandra.net/htdocs
    ... rest of my config
    
    Code (markup):
    You may have to use mod_rewrite if it is compiled into the server and you do not have access to the configuration files, either directly or through cpanel. Using mod_rewrite is a little tricky to handle all the boundary conditions.

    Note: if any of your sites are submitted to directories, it may pay you to redirect the non www to your www site to avoid confusion. Some directories require their editors to list the www version if it works and there has been a fair amount of talk about which search engines "do the right thing". Safest thing to do is to pick www.domain.tld as your main address and redirect domain.tld to it.
     
    ziandra, Jun 14, 2005 IP
    SEbasic likes this.
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You can do this through IIS configuration.

    * in your DNS map domain.com to the same IP address as www .domain.com
    * create a new website (same IP address) and type domain.com in the Host edit box
    * check Properties > Home Directory > A redirection to a URL and type www .domain.com in the URL edit box

    That's it. All requests to domain.com will be redirected to www .domain.com.

    J.D.
     
    J.D., Jun 14, 2005 IP
    SEbasic likes this.
  8. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I love this forum... :D

    Thanks guys. :)
     
    SEbasic, Jun 15, 2005 IP