HTML or PHP Redirect Page Advice

Discussion in 'Web Design and Development' started by jdl8422, Nov 10, 2008.

  1. jdl8422 macrumors 6502

    jdl8422

    Joined:
    Jul 5, 2006
    Location:
    Louisiana
    #1
    I have a domain and I want to redirect it to a new site. I want to use a HTML page or PHP page, which ever works, and when they go to this site its just an image and a message that says "www.siteX.com has moved to www.siteY.com. You will be directed in 5 seconds" Ive seen similar php code in email forms. Something along the lines of: if success thankyou.html. Any ideas on how to do this, or where I can find out?. Thanks

    PS: This is not for spam or anything like that. These are both my sites
     
  2. ergdegdeg Moderator emeritus

    ergdegdeg

    Joined:
    Oct 13, 2007
    #2
    Why didn't you google? It's fairly easy and popular. W3C link.
     
  3. jdl8422 thread starter macrumors 6502

    jdl8422

    Joined:
    Jul 5, 2006
    Location:
    Louisiana
    #3
    I was looking for the best way, I didnt want to risk the chance of being marked as any kind of spam because I read that you can be de-indexed.
     
  4. ergdegdeg Moderator emeritus

    ergdegdeg

    Joined:
    Oct 13, 2007
    #4
    Well, I don't think there's a better way than what W3C officially suggests.
     
  5. jdl8422 thread starter macrumors 6502

    jdl8422

    Joined:
    Jul 5, 2006
    Location:
    Louisiana
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    As an added piece, having that one file will only apply to people that go to your home page. If they've bookmarked any other page than that, they will see a error 404 page instead. You can create a redirect page for each page that was at the site, but that would be laborious and unnecessary.

    If your old site is on an Apache web server, you can create some redirects from there. You can go about this two ways, either redirect to your new site or redirect to your redirect page. The latter helps orient people to realize your site has moved so can be helpful. Though, if your site has retained its structure (i.e., olddomain.com/a_page.html = newdomain.com/a_page.html) then you could use the Apache redirect to put them on the page they really want, rather than at the home page of your new site. So there's pros and cons of both ways. I'll leave it to you to decide what will be best for your situation.

    OK, so how to do the redirects:

    Basic .htaccess file for redirect: (only use one of the numbered options below)
    Code:
    [B]RewriteEngine On[/B]
    # 1.) assumes new site has same structure
    [B]Redirect permanent /(.*) http://www.newdomain.com/$1[/B]
    # 2.) redirect visitor to your redirect page on old web site (assuming your
    #      redirect page is index.html in the root directory
    [B]Redirect permanent /.+ http://www.olddomain.com/[/B]
    
    Place the .htaccess file in your root folder of the site.

    Links for reading:
    http://httpd.apache.org/docs/1.3/mod/mod_alias.html
    http://www.yolinux.com/TUTORIALS/ApacheRedirect.html
    http://www.webmasterworld.com/forum92/82.htm
     

Share This Page