Redirect all pages of old domain to new domain root *without parameters*

Discussion in 'Apache' started by Bernard, Oct 14, 2011.

  1. #1
    I've been scouring the web for an answer and I haven't found it yet. I'm currently using:
    RedirectMatch 301 ^(.*)$ http://www.newdomain.com
    Code (markup):
    to redirect all pages of old domain to the new domain root. However, pages on the old domain with parameters (like ?t=66) are being directed to the new domain with parameters (like newdomain.com/?t=66). Is there a way to get all pages to redirect to the domain root cleanly (without parameters)?
     
    Bernard, Oct 14, 2011 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    If you append ? to the redirect, it should clear the query params, or use the QSD (Query String Discard) flag at the end.
     
    zacharooni, Oct 15, 2011 IP
  3. Bernard

    Bernard Well-Known Member

    Messages:
    1,608
    Likes Received:
    107
    Best Answers:
    0
    Trophy Points:
    185
    #3
    I ended up using the following solution suggested to me on another forum:
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteRule (.*) http://www.example.com/? [R=301,L]
    Code (markup):
     
    Bernard, Oct 17, 2011 IP
  4. contentmegaguru

    contentmegaguru Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    this is greata... i was having a similar problem, i'm gonna try this.
     
    contentmegaguru, Oct 17, 2011 IP
  5. nazy.exe

    nazy.exe Member

    Messages:
    96
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #5
    if you using wordpress, you can use redirect 301 plug in.. it's custom page to redirect any page domain,,
     
    nazy.exe, Oct 17, 2011 IP