Quick .htaccess query, rep+ for answering

Discussion in 'Apache' started by kgrad, Feb 7, 2011.

  1. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Put this on olddomain.com .htaccess
    RewriteEngine On
    RewriteRule ^$ http://newdomain.com/page1.html [R=301,L]
    RewriteRule ^page1\.html$ http://newdomain.com/another-page.html [R=301,L]
    RewriteRule ^page2\.html$ http://newdomain.com/some-page.html [R=301,L]
    RewriteRule ^page3\.html$ http://newdomain.com/new-page.html [R=301,L]
    Code (markup):
     
    mwasif, Feb 7, 2011 IP
    kgrad likes this.
  2. kgrad

    kgrad Well-Known Member

    Messages:
    2,414
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    130
    #3
    thanks mwasif!

    Another quick question:

    if my olddomain pages are olddomain.com/page-one/ then would the following be correct?

    RewriteRule ^page-one\$ http://newdomain.com/another-page.html [R=301,L]


    thanks for your help
     
    kgrad, Feb 8, 2011 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    This will work for both olddomain.com/page-one and olddomain.com/page-one/ (note the difference of trailing slash)

    RewriteRule ^page-one/?$ http://newdomain.com/another-page.html [R=301,L]
     
    mwasif, Feb 8, 2011 IP