Remove parameters with .htaccess

Discussion in 'HTML & Website Design' started by hovesh07, Feb 5, 2010.

  1. #1
    Hi,

    How do I do a 301 redirect for a URL like

    http://www.mydomain.com/index.php?rss_id=some%20text
    
    Code (markup):
    to become just

    http://www.mydomain.com
    
    Code (markup):
    I want to remove some URL from the search engine's list (Bing, in this case).

    Thanks!
     
    hovesh07, Feb 5, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
  3. hovesh07

    hovesh07 Well-Known Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    I emailed them.
    It's more than one URL and more than one site, so I'm looking for an .htaccess solution like:

    RewriteRule ^rss_id([^/\.]+)?$ / [R=301,L]
    Code (markup):
    This doesn't seem to work for me. Any ideas?
     
    hovesh07, Feb 6, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You may be able to do a RedirectMatch 301 or something.. not too good at regex or anyhting m yself

    if you have access to the PHP source, you could do

    if(isset($_GET['rss_id'])){header('HTTP/1.1 301 Moved Permanently');header('Location: /');}
     
    krsix, Feb 6, 2010 IP
  5. WebhostListin

    WebhostListin Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The ^ before rss_id stands for beginning of the path, so it won't match the URLs you are trying to redirect and hence won't work.

    Try changing it to:
    RewriteRule ^/index.php?rss_id([^/\.]+)?$ / [R=301,L]
    Code (markup):
     
    WebhostListin, Feb 6, 2010 IP
  6. hovesh07

    hovesh07 Well-Known Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #6
    RewriteRule ^index.php(.*)$ /? [R=301,L]
    Code (markup):
    The ? after the / clinches it.
     
    hovesh07, Feb 6, 2010 IP
  7. hovesh07

    hovesh07 Well-Known Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #7
    I tried in on another webhost (1&1) and it didn't work.

    This seems to work, though:

    RewriteCond %{QUERY_STRING} rss_id=(.*)
    RewriteRule ^index.php(.*) /? [R=301,L]
    
    Code (markup):
     
    hovesh07, Feb 6, 2010 IP