Mod rewrite for search page

Discussion in 'Apache' started by dan101, May 27, 2010.

  1. #1
    Hi,

    I need my .htaccess to work properly with

    www.domain.com/search/[B]keyword[/B]
    and
    www.domain.com/search/?=[B]keyword[/B]
    Code (markup):
    //At this moment works only the part with www.domain.com/search/[B]keyword[/B]
    //This is the code that I use
    RewriteRule ^search/(.*)$ /search.php?key=$1
    Code (markup):
    So I need a fix for www.domain.com/search/?=keyword
    I tried
    RewriteRule ^search/?=(.*)$ /search.php?key=$1
    Code (markup):
    but is not working

    Thank you
     
    dan101, May 27, 2010 IP
  2. dan101

    dan101 Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nobody knows?
     
    dan101, Jun 5, 2010 IP
  3. aeroz1

    aeroz1 Active Member

    Messages:
    492
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Mod rewrite tips and tricks;
    instant 301 from old dynamic url to new static url
    (will only work if you use the exact variables from the dynamic url).Reg Expression notes:
    [^&]+ mean find any character except the "&" since it is what seperates the variables in a string. you can back reference matches in a rewrite condition using ()'s just like your rewrite rules but to call them you have to use a % instead of a $.

    Benefits:
    1. You don't have to hand write 1,000's of 301 redirects

    2. Spiders can easily pick up the 301 and pass the scores and index the new urls much faster than having to crawl the entire site over from scratch.

    3. Users clicking old dynamic urls in the SERPS will not get a 404 error. They'll go straight to the new static urls.
    Change a product name or change a mispelling and you've just lost all page scores to the static mod rewritten url. Unless...

    Example url:
    www.somesite.com/dinnerplates/cassa-stone/
    Should be spelled
    www.somesite.com/dinnerplates/casa-stone/
    Make the unormalized, normalized for Yahoo!'s sake.

    Example code:
    <a href="some-directory/">some directory</a>Google is very good at indexing and scoring exactly what is in the <a href> tag whether the url is normalized or not. Yahoo on the other hand is a stickler for normalization and will index the example above like so in there SERPS http://www.somesite.com/some-directory
     
    aeroz1, Jun 7, 2010 IP
  4. dan101

    dan101 Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    dan101, Jun 7, 2010 IP