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.

htaccess 301 redirect from ?id=1 to mysite.com

Discussion in 'Apache' started by WarBud, Mar 15, 2008.

  1. #1
    I'm trying to get all the dynamic links like these:
    mysite.com/index.php?id=1
    mysite.com/index.php?id=2
    mysite.com/index.php?id=3
    etc.

    to 301 redirect to:
    mysite.com

    Any help would be appreciated.
    Thanks.
     
    WarBud, Mar 15, 2008 IP
  2. Isaak

    Isaak Guest

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're being very vague so I'm going to show you a php solution:
     
    Isaak, Mar 19, 2008 IP
  3. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this in .htaccess:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^id=
    RewriteRule ^index\.php$ http://www.my_site.com/? [L,R=301]
    
    Code (markup):
    I believe that Isaak's suggestion is going to give a 302 redirect.

    Jean-Luc
     
    Jean-Luc, Mar 19, 2008 IP
  4. WarBud

    WarBud Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just an FYI. This is what I finally got to work:

    RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ [NC]
    RewriteRule ^index.php$ [url]http://www.mysite.com/page.php?id=%1[/url] [R=301,L]
    Code (markup):
    Thanks for the help.
     
    WarBud, Apr 8, 2008 IP