SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod_rewrite help!!

    Ok, So i am trying to seo my urls. So far this is what I have and its not working.... Basically I need to be able to go to www.mysite.com/alabama.html and also www.mysite.com/alabama/araphaho.html, but when I get one working the other does not. The city is state is passed as a query string... Heres my code so far....

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{QUERY_STRING} ([^=]*)=(.*)
    RewriteRule (.*)\.html$ /browse.php?state=$1 [R]

    RewriteRule ^(.*)/(.*)\.html$ /rate-page.php?state=$1&city=$2 [N,L]


    this only works when I go to www.mysite.com/california/san diego.html

    but not www.mysite.com/california.html


    Help!!

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    TyTy,

    PLEASE read my signature's tutorial on mod_rewrite as my regex development uses exactly the state/city example you're looking for. THEN be sure that the most specific regex rule is used first (pay attention to replacing (.*) because it is INAPPROPRIATE, i.e., it's "greedy").

    Using correct regex is the key.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •