301 redirect

Discussion in 'Apache' started by raj_2006, Apr 13, 2012.

  1. #1
    Hi Guys,

    I am facing a problem in redirecting a old url to new url.

    For eg.

    I want to redirect

    http://olddomain.com/ and http://olddomain/(query param)

    to

    http://www.newdomain.com/ and http://www.newdomain.com/(query param)

    So what I was doing

    RewriteCond %{HTTP_HOST} ^.*olddomain.com [NC]
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
    Code (markup):
    It works for http://olddomain.com and it redirects to http://www.newdomain.com but when there is query string it doesn't take to the right url.

    so http://olddomain/(query param) doesn't redirect to http://www.newdomain.com/(query param).I guess there is something with (.*).Do I need to put it at the end as well but not sure where to put.

    I am really lost.Please suggest.

    Thanks in advance.

    Raj
    Edit/Delete Message
     
    raj_2006, Apr 13, 2012 IP
  2. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #2
    This is strange. If you don't append something new, then the original query is passed through by default.
    What is the redirect target of http://olddomain/(query param)?
     
    weppos, Apr 16, 2012 IP