Htaccess Mod Rewrite trouble

Discussion in 'Search Engine Optimization' started by Nocturne, Oct 1, 2009.

  1. #1
    Hi all,

    I'm trying to make my url's seo friendly, but I can't quite wrap my head around all the configuration options of mod rewrite.

    I have this in my htaccess file:

    RewriteRule ^browse/([0-9]+)/.*_online_review[/]?$ show.php?id=$1&redirect=true{QUERY_STRING} [QSA,L]

    Both, url's work. For example /browse/546/thisbook_online_review and /show.php?id=1101. But I'm trying to redirect (301) this "/show.php?id=1101" to this "/browse/546/thisbook_online_review" as google has both links indexed, which isn't good.

    I've tried to do this [R=301,QSA,L], but the result is a 404 error.

    Any ideas / help is appreciated.

    Thanks!
     
    Nocturne, Oct 1, 2009 IP
  2. Canonical

    Canonical Well-Known Member

    Messages:
    2,223
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Without knowing all of the SEO friendly URLs and their corresponding SEO un-friendly URLs, it's hard for me to give you a "generic" solution. But generally speaking, when trying to make SEO un-friendly URLs SEO friendly it involves 2 sets of RewriteRules - one that is a redirect, another that is a URL rewrite.

    For example, if "/browse/546/thisbook_online_review" is your SEO friendly URL and "/show.php?id=1101" is its SEO un-friendly equivalent then I might setup something like the following in my root .htaccess:


    BTW using underscores in your folder and page names is NOT SEO friendly. Google does NOT recognize the underscore as a word separator. You should be using hyphens.
     
    Canonical, Oct 1, 2009 IP