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.

Mod rewrite question

Discussion in 'Apache' started by ian_ok, Jun 22, 2005.

  1. #1
    I'm new to all this rewrite stuff, so am looking for some advise on the following:

    RewriteEngine On

    #listing_browse
    RewriteRule ^listing_browse.html listing_browse_test.php

    This is an extract of what I'm doing which will make my php database pages into html.

    My query is:

    When a users types in w w w.mydomain/listing_browse_test.php this .php file appears SHOULDN'T it be the .html ???
    SEMrush
    Or am I barking up the wrong tree?

    Ian
     
    ian_ok, Jun 22, 2005 IP
    SEMrush
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand your question correctly, no. Think of it like this:

    RewriteRule alternate.url real.url
    Code (markup):
    The real url (search engine unfriendly one) will always work. The re-written URL (search engine friendly one) is given as an alternative. So you are telling the webserver "if someone asks for alternate.url I know it doesn't actually exist in the file system so give them real.url instead and let them think that alternate.url actually exists".
     
    tflight, Jun 22, 2005 IP
  3. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for that, I understand what you are saying.

    So for all my database pages where my .php?$12 will become -12.html people will still be able to go to the .php?$12 page but the BOTS will crawl and start indexing the -12.html so any updates by the SE will result in the -12.html being shown and the .php?$12 will drop out over time.

    Ian
     
    ian_ok, Jun 22, 2005 IP
  4. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #4
    The bots will only see the .html version by following a link to a page with that extension.

    For your OpenRealty site you might consider the "site map" mod which dynamically generates a list of static links with the .html extension.

    Here is an example.
     
    ResaleBroker, Jun 22, 2005 IP
  5. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, so long as there are no more links to the old urls. You might also want to put redirects on the old urls to the new urls so SEs don't think they are just a bunch of duplicate pages with different URLs.... I made that mistake once.
     
    tflight, Jun 22, 2005 IP
  6. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks all, yes I think it was the comment that tflifht made about old urls still being around.

    BUT

    How would you implement a redirect when you all ready have a re-write on that page?

    Ian
     
    ian_ok, Jun 22, 2005 IP
  7. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #7
    RewriteRule ^old.url$ new.url [R=301,L]
    RewriteRule alternate.url real.url
    Code (markup):
    If I remember right that is how I did it.
     
    tflight, Jun 22, 2005 IP
  8. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I'm a little (WELL A LOT) confused:

    This is a link from msn
    w w w . costay sierra.com /listingview.php?listingID=55

    This page is NOW:
    w w w . costay sierra.com /propiedades-en-venta-55.html

    AND
    /listing_browse.php IS NOW /ventas.html

    This is my htaccess file
    #listingview
    RewriteRule ^propiedades-en-venta-([0-9]*).html listingview.php?listingID=$1
    RewriteRule ^propiedades-en-venta.html listingview.php
    
    #listing_browse
    RewriteRule ^ventas.html listing_browse.php
    RewriteRule ^ventas_page-([0-9]*).html listing_browse.php?cur_page=$1&
    RewriteRule ^ventas.html listing_browse.php?sortby=price&sorttype=DESC&
    
    #viewimage
    RewriteRule ^viewimage.html viewimage.php
    RewriteRule ^viewlistingimage-([0-9]*).html viewimage.php?imageID=$1&type=listing
    Code (markup):
    You can still go to the listingview.php?listingID=55 so where do I put the [301,L] that you mentioned!!!

    Ian
     
    ian_ok, Jun 23, 2005 IP
  9. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #9
    RewriteRule ^propiedades-en-venta-([0-9]*).html listingview.php?listingID=$1 [R=301,L]

    If I understand correctly. :)
     
    tflight, Jun 23, 2005 IP
  10. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks for all your help Tim. One final Q.

    Does this mean that after X amount of time I can change the .php files mentioned above to .html and add the appropiate the following code to make html act as php.

    AddType application/x-httpd-php .php .htm .html

    i.e. listingview.php to propiedades-en-venta-

    This is now my htaccess file:
    
    #listingview
    RewriteRule ^propiedades-en-venta-([0-9]*).html listingview.php?listingID=$1 [R=301,L]
    RewriteRule ^propiedades-en-venta.html listingview.php [R=301,L]
    
    #listing_browse
    RewriteRule ^ventas.html listing_browse.php [R=301,L]
    RewriteRule ^ventas_page-([0-9]*).html listing_browse.php?cur_page=$1&
    RewriteRule ^ventas.html listing_browse.php?sortby=price&sorttype=DESC&
    
    #viewimage
    RewriteRule ^viewimage.html viewimage.php [R=301,L]
    RewriteRule ^viewlistingimage-([0-9]*).html viewimage.php?imageID=$1&type=listing
    Code (markup):
    Ian
     
    ian_ok, Jun 23, 2005 IP
  11. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #11
    OK, just worked out that NO I can't change the files after X amount of time, amazing what a good nights sleep will do!

    Does the htaccess look fine?

    Ian
     
    ian_ok, Jun 24, 2005 IP
  12. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #12
    It looks okay to me, but looks can be deceiving. :) Test the URLs and if they work as planned then there you go!
     
    tflight, Jun 24, 2005 IP
    ian_ok likes this.
  13. justicewhite

    justicewhite Well-Known Member

    Messages:
    240
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    138
    #13
    tflight, you might be able to get much more detailed help on this stuff on the open-realty.org forum.
     
    justicewhite, Jun 24, 2005 IP
  14. ian_ok

    ian_ok Peon

    Messages:
    551
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I had to remove the [r=301,L] as it was stopping the rewrites from working

    ian
     
    ian_ok, Jun 26, 2005 IP