1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

quick help with htaccess...PLEASE!!!

Discussion in 'Apache' started by cgo85, Dec 8, 2004.

  1. #1
    I'm trying to rewrite my urls. Here is an example of one of my urls:

    search-realestate.net/ca-city.php?realtor=Alameda

    I tried using something like:

    RewriteEngine on
    RewriteRule ^([a-z][a-z])-realtor_(.*)\.html$ /([a-z][a-z])-city.php?realtor=$1 [L]

    I've tried a couple of different things and either I get a 403 error or a page cannot be found error.

    I'm kind of lost right now trying to learn how to do this Please help me!!!!
     
    cgo85, Dec 8, 2004 IP
  2. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think that you need at least one RewriteCond in there, and your RewriteRule is slightly off - you need to use both of the patterns in brackets in your target URL.
    You could try

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.search-realestate.net
    RewriteRule ^([a-z][a-z])-realtor_(.*)\.html$ /$1-city.php?realtor=$2 [L]

    I think that that should do it.

    Hope it helps

    John
     
    johnt, Dec 8, 2004 IP
  3. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What would that change the url to look like?
     
    cgo85, Dec 8, 2004 IP
  4. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That would change static looking HTML URLs into dynamic PHP URLs, but the user ( and bot ) would still see the HTML URL, which I think is what you're trying to do.

    If a user or bot requested
    search-realestate.net/ca-realtor_Alameda.html​
    then the page which would be served would be
    search-realestate.net/ca-city.php?realtor=Alameda​

    likewise
    search-realestate.net/ny-realtor_Someoneelse.html​
    would become
    search-realestate.net/ny-city.php?realtor=Someoneelse​

    You could also try only having 1 php script called city.php, rather than one per city which I guess you currently do from your original RewriteRule, then you could pass the city identifiers into the script as a parameter using this RewriteRule instead of the earlier one.

    RewriteRule ^([a-z][a-z])-realtor_(.*)\.html$ /city.php?realtor=$2&city=$1[L]​

    Hope this clears it up

    John
     
    johnt, Dec 8, 2004 IP
  5. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Johnt, you've been very helpful thank you. As you advised I made one city page. Ok here is the issue... Here is a sample link:

    /mls/city.php?realtor=Kuna&state=Idaho

    I want the bots and users to see as: /realtor/Idaho/Kuna.htm

    So basically: /realtor/state/city.htm

    One more thing... When I link to this page would i link to it as:

    /mls/city.php?realtor=Kuna&state=Idaho

    or

    /realtor/Idaho/Kuna.htm

    I really appreciate your help!!!
     
    cgo85, Dec 8, 2004 IP
  6. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I knew that I wasn't too stupid!!! After toying with a bunch of different rewrites I contacted my hosting company cause I knew that something had to be up. Anyhow, they don't allow rewrite configuration on there servers at this time. Thanks anyway johnt.
     
    cgo85, Dec 8, 2004 IP