Redirect with .htaccess

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mobile_1

    #1

    Redirect with .htaccess

    I am trying to fix a problem where Google has indexed the wrong version of a
    URL. I need to redirect the bad version to the good version with 301
    redirects.

    I've tried a couple of things, but it's not working.

    The bad URLs look like this:
    /search.php?mode =search&narrow_ cat=2&term=Worl d,%20Hello&page =1

    That should redirect to:
    /dir/Hello_World

    This one doesn't work at all:
    RewriteRule
    ^search\.php\?m ode=search&narr ow_cat=[0-9]{1,2}&term=([A-Z]{1}[a-z]+),%20([A-Z]{1}[a-z]+)&page=1$
    http://www.example.com/dir/$2_$1 [R=301,NC,L]


    This one works, except it doesn't include the "Hello" and the "World", only
    the underscore:

    RewriteCond %{QUERY_STRING}
    mode=search&nar row_cat=[0-9]{1,2}&term=([A-Z]{1}[a-z]+),%20([A-Z]{1}[a-z]+)&page=1$
    RewriteRule ^search\.php http://www.example.com/dir/$2_$1 [R=301,NC,L]

    Any ideas?


  • Kimmo Laine

    #2
    Re: Redirect with .htaccess

    "mobile_1" <mobile_1@nospa m.invalidwrote in message
    news:12mp3j5a79 j4pd2@corp.supe rnews.com...
    >I am trying to fix a problem where Google has indexed the wrong version of
    >a URL. I need to redirect the bad version to the good version with 301
    >redirects.
    Just use a robots.txt to tell googlebot not to index the wrong page. And
    also go ask the Apache questions in an apache group, this is c.l.php...



    --
    "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
    http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
    spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


    Comment

    • mobile_1

      #3
      Re: Redirect with .htaccess

      "Kimmo Laine" <spam@outolempi .netwrote in message
      news:lJabh.6211 5$vz5.12760@rea der1.news.jippi i.net...
      "mobile_1" <mobile_1@nospa m.invalidwrote in message
      news:12mp3j5a79 j4pd2@corp.supe rnews.com...
      >>I am trying to fix a problem where Google has indexed the wrong version of
      >>a URL. I need to redirect the bad version to the good version with 301
      >>redirects.
      >
      Just use a robots.txt to tell googlebot not to index the wrong page. And
      also go ask the Apache questions in an apache group, this is c.l.php...
      Sorry, I didn't know about the Apache group.

      Robots.txt isn't as good as a redirect since it abandons the PageRank of the
      indexed versions.

      I found an answer: use %1 and %2 instead of $1 and $2.



      Comment

      Working...