Help with mod_rewrite

Discussion in 'Site & Server Administration' started by pcoulter, Mar 26, 2010.

  1. #1
    Hey guys - I'm having problems rewriting some dynamic URLs on my website. Bear with me as I'm not a programmer.

    I want to re-direct http://www.citydreamhomes.com/search.php?location1=1
    to: http://www.citydreamhomes.com/downtown-toronto-homes.html

    Here's my .htacess file

    RewriteEngine ON

    #RewriteRule ^product/([^/\.]+)/?$ product.php?id=$1 [L]

    RewriteRule ^(.*)/downtown_toronto_homes/$ $1/search.php?location1=1


    It doesn't seem to be working, and although my hosting company says that mod_rewrite is enabled, is doesn't show as loaded in the phpinfo file.

    Any help would be highly appreciated!
     
    pcoulter, Mar 26, 2010 IP
  2. pcoulter

    pcoulter Active Member

    Messages:
    279
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Anyone?

    I will pay $5 by PayPal to anyone who can tell me what`s wrong with:

    RewriteEngine on

    RewriteRule ^(.*)/downtown_toronto_homes\.html$ $1/search.php?location1=1
     
    pcoulter, Mar 28, 2010 IP
  3. lkraj

    lkraj Greenhorn

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #3
    Try this

    RewriteRule ^/(.*)\.html$ /search.php?location1=$1

    The above will redirect
    http://www.citydreamhomes.com/downtown_toronto_homes.html to http://www.citydreamhomes.com/search.php?location1=downtown_toronto_homes
    http://www.citydreamhomes.com/north_york_homes.html to http://www.citydreamhomes.com/search.php?location1=north_york_homes

    You need to change search.php, to accept instead of numbers, 1 or 5 etc, to accept downtown_toronto_homes or north_york_homes. Actually this will simplify the code in search.php as well.

    I don't need the $5, I will be glad if the above solution works for you.
     
    lkraj, Mar 29, 2010 IP