homepage Welcome to WebmasterWorld Guest from 107.20.109.52
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
Redirects For Fun And Profit - Part 1
FAQ: How to move a site to a new domain?
bakedjake




msg:672625
 7:12 pm on Jun 16, 2004 (gmt 0)

Commonly Used Redirects For Moving To A New Domain

Most of these are lifted from, slightly modified, or examplified forms of posts here at WebmasterWorld and summarized here for reference. Thanks to skipfactor, pageoneresults, korkus2000, Xoc, jdMorgan, Decius, and Daiman for their posts on these topics.

Case: You are transferring from www.example-old.com to www.example-new.com. The architecture of the site will remain the same - you simply want to switch to a new domain name. You want to pass related page and parameter information.

Server Level Redirects

Apache (mod_rewrite)

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]

IIS (Built In Rewrite Module)

  • Right click on site (www.example-old.com) in IIS Manager, select Properties
  • Click on "Home Directory" tab
  • Select the "A redirection to a URL" option
  • In the "Redirect to" box, place the text

    http://www.example-new.com$V$Q

  • Select the "The exact URL entered above" option
  • Select the "A permanent redirection for this resource" option

    Language Specific Redirects

    see below

    [edited by: oilman at 8:18 pm (utc) on June 16, 2004]

  •  

    bakedjake




    msg:672626
     7:34 pm on Jun 16, 2004 (gmt 0)

    This PHP code should handle any parameters:

    <?php

    [pre]header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.example-new.com" .
    $_SERVER['SCRIPT_NAME'] . '?' .
    $_SERVER['QUERY_STRING']);
    exit();
    [/pre]

    ?>

    bakedjake




    msg:672627
     7:43 pm on Jun 16, 2004 (gmt 0)

    This Perl code should handle any parameters:

    print "Status: 301 Moved Permanently\r\n" .
    "Location: http://www.example-new.com" .
    "$ENV{'SCRIPT_NAME'}?$ENV{'QUERY_STRING'}\r\n" .
    "\r\n";

    [edited by: oilman at 8:23 pm (utc) on June 16, 2004]

    bakedjake




    msg:672628
     7:59 pm on Jun 16, 2004 (gmt 0)

    This ASP code should handle any parameters:

    <%
    Response.Status = "301 Moved Permanently"
    Response.AddHeader "Location", "http://www.example-new.com" _
    & Request.ServerVariables("SCRIPT_NAME") _
    & "?" & Request.ServerVariables("QUERY_STRING")
    Response.End
    %>

    thaedge




    msg:672629
     7:16 pm on Jul 1, 2004 (gmt 0)

    Yes but what about when they are changing the directory structure :( Shall be a pain to keep my listings and traffic going while we do this.

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved