1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How To 301 Redirect Queries?

Discussion in 'Apache' started by Pieterk, Feb 18, 2013.

  1. #1
    I have just upgraded my website, and set 301 redirects for all old pages.

    But on the old website I used a search engine, and in Google Webmaster there are loads of 404 pages with search queries. They look like this: www.mydomain.com/search.php?filter=monitor&q=merchant&sort=price

    Simply redirecting search.php doesn't help, so I guess I need to use a wildcard?
    I have never done anything like this, so maybe someone can tell me how to do this?

    Thanks!
     
    Solved! View solution.
    Pieterk, Feb 18, 2013 IP
  2. #2
    Try using this:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^filter=(.*)&q=(.*)&sort=(.*)$ [NC]
    RewriteRule ^search.php$ /your-new-search-url/filter-%1/q-%2/sort-%3/? [L,R=301]
    Code (markup):
    Above snippet will redirect all your search queries to your new url along with entered parameters. So in the line 3 you need to change the last part to your actual url. In the case you just want to redirect all those pages and cut off old queries then replace line 3 with this one:
    RewriteRule ^search.php$ /your-new-search-url/? [L,R=301]
    Code (markup):
     
    pr0t0n, Feb 28, 2013 IP
  3. Pieterk

    Pieterk Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    That works. Thanks!
     
    Pieterk, Mar 1, 2013 IP