Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Any .htaccess wizards out there ?

Discussion in 'SEO Search Engine Optimisation' started by LumpyBumps, Nov 7, 2010.

Thread Status:
Not open for further replies.
  1. LumpyBumps

    LumpyBumps Member

    Joined:
    May 2007
    Posts:
    43
    Likes Received:
    2
    Does anyone know how to write the htaccess rule so that urls containing parameters can be redirected to the root url ?

    In other words I want to redirect:

    index.php?blah=fred&bob=joe

    to:

    index.php only ?

    This is to stop Google indexing multiple versions of the same page (loooong story !)

    Cheers

    Phil
     
  2. osxkris

    osxkris Member

    Joined:
    Jan 2009
    Posts:
    15
    Likes Received:
    4
    I haven't tested this, but something like the following should do the trick:

    RewriteRule ^index\.php\?.+$ index.php [R=301]
     
  3. Ashton Canada

    Ashton Well-Known Member

    Joined:
    Feb 2010
    Posts:
    1,566
    Likes Received:
    28
    Last edited: Nov 7, 2010
  4. LumpyBumps

    LumpyBumps Member

    Joined:
    May 2007
    Posts:
    43
    Likes Received:
    2
    Nope, it didn't work I'm afraid. The test url index.php?blah=fred remains in the address bar. That's as far as I managed to get myself.

    Any ideas ?

    Phil
     
  5. retired_member21

    retired_member21 Retired Member

    Joined:
    Apr 2008
    Posts:
    734
    Likes Received:
    13
  6. LumpyBumps

    LumpyBumps Member

    Joined:
    May 2007
    Posts:
    43
    Likes Received:
    2
    Thanks Nick, can't quite get my head around that but I think that it's close to what I want. Maybe after some food I'll figure it out !

    @Ashton: thanks for the tip. Not sure that it's applicable in this instance but I'll definately use that to ensure that inbound links to different versions of the domain are treated correctly.
     
  7. mat

    mat Well-Known Member

    Joined:
    Apr 2007
    Posts:
    3,860
    Likes Received:
    110
    How about something like this?

    RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
    RewriteRule ^index\.php$ /index.php? [R=301]
     
Thread Status:
Not open for further replies.