how to change doamin and redirect all archived links to the new one

Discussion in 'Apache' started by shuman202, May 6, 2010.

  1. #1
    i wanna change the domain name and redirect all archived links to the new one not only the main page
    for examble
    http://www.web-design-wiki.com/
    to
    http://www.kootta.org

    and all the rest for examble
    http://www.web-design-wiki.com/php-tutorial.html

    to
    http://www.kootta.org.php-tutorial.html

    i know i have to edite the .htaccess file but i don't know how to achieve it

    i have a live example for the same thing i wanna do
    is redirecting all google archived links from the following domain
    http://www.fomny.com/

    to
    http://www.watchfomny.com

    sorry for my english it's not my language
     
    shuman202, May 6, 2010 IP
  2. Namjies

    Namjies Peon

    Messages:
    315
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yeah, on your old domain, place this in .htaccess

    
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    
    Code (markup):
    The (.*) means any string, ^ and $ beeing the delimiters for the url used in the rewrite.

    Followed with the new domain, with $1 at the end ( the anything (.*) stored previously)

    Followed by the last tag [R=301,L] , which includes R=301 for a "301 Moved Permanently" redirect.

    ~~~~~~~~~~~~~~
    On the new domain, also add this with www or without www, uses the same method:

    # Always www
    RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

    it will prevent to have 2 indexed result for each page (with/without www) or have inconsistencies in your incoming links. With the moved permanently, you shouldn't lose any benefits.

    you can also do this with subdomains, which often end up beeing accessible as subdomain.domain.com or domain.com/subdomainfolder

    ~~~~~~~~~~~~~~

    Lots of nice protections and tweaks that can be done in .htaccess :p

    Custom not found pages... clean urls... block query strings...
     
    Namjies, May 6, 2010 IP
  3. shuman202

    shuman202 Well-Known Member

    Messages:
    638
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    145
    Digital Goods:
    1
    #3
    thank you for your help
     
    shuman202, May 7, 2010 IP