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.

Dynamic to Static URL [Mod_rewrite]

Discussion in 'Programming' started by ResaleBroker, Oct 1, 2004.

  1. #1
    I would like to use a mod_rewrite to change certain dynamic URLs on my site to static.

    I have read many of the threads on this topic but none give an example of the rewrite.

    I have also searched the web and I couldn't get any of the proposed solutions to work.

    An example of my current URL is:
    http://www.azmultiplelistingservice.com/listings/listingview.php?listingID=145

    I would like it to look something like this:
    http://www.azmultiplelistingservice.com/listings/listingview-145

    Can anyone help?
     
    ResaleBroker, Oct 1, 2004 IP
  2. expat

    expat Stranger from a far land

    Messages:
    873
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    taken from live site ....nix system

    RewriteBase /
    RewriteRule ^who-flies-where-(.*)-(.*).htm$ europe-who-flies-where.htm?ww_from=$1&ww_to=$2

    changes /europe-who-flies-where.htm?ww_from=lon&ww_to=spain

    /who-flies-where-lon-spain.htm

    but resolves it to the original so no code change...
    M

    http://www.departures-arrivals.com/who-flies-where-lon-spain.htm
     
    expat, Oct 1, 2004 IP
  3. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Here is my latest attempt.

    RewriteEngine on
    Options +FollowSymlinks +MultiViews
    RewriteBase /
    RewriteRule ^listingview.php?listingID=([A-Z0-9]+) listing-$1
     
    ResaleBroker, Oct 1, 2004 IP
  4. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The setting up of the static html URL is not that difficult, but what I have had problems with in the past is then implementing it on to the website, so that the spiders, and visitors to the website only see the html not php Url's on links etc.
     
    DarrenC, Oct 1, 2004 IP
  5. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #5
    I don't mind the php URL's. I'm wanting to make the dynamic URL more spider friendly by removing the [?] and the [ID] from the URL.
     
    ResaleBroker, Oct 1, 2004 IP
  6. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Still looking for a solution.

    Bueler?

    Bueler?
     
    ResaleBroker, Oct 2, 2004 IP
  7. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #7
    This does it:

    RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1
     
    ResaleBroker, Oct 4, 2004 IP
  8. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi ResaleBroker

    Will have to wait for this one as there is some work to get this to work 100%.

    Ah found it

    RewriteEngine on
    # Redirect internally
    # listingview/1/ to listingview.php?listingID=1
    # I added the rewrite=yes in the query string
    # this is a trick to avoid an infinite loop

    RewriteRule ^listingview/([0-9]+)/?$ listingview.php?listingID=$1&rewrite=yes [NC,L]

    # remove sessions from site
    php_value session.use_trans_sid 0

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

    Al
     
    awddesign, Oct 4, 2004 IP
  9. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi

    here is another code for you:



    #php.ini configuration
    <IfModule mod_php4.c>
    php_value session.use_trans_sid 0
    </IfModule>

    php_flag display_errors Off
    php_flag register_globals On
    php_flag track_vars On

    RewriteEngine On

    #index
    Rewriterule ^index.html index.php

    #listingview
    RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1
    RewriteRule ^listingview.html listingview.php
    RewriteRule ^listingviewprint-([0-9]*).html listingview.php?listingID=$1&printer_friendly=yes

    #listing_browse
    RewriteRule ^listing_browse.html listing_browse.php
    RewriteRule ^rental_browse.html listing_browse.php?type=Rental

    #userview
    RewriteRule ^userview.html userview.php
    RewriteRule ^userview-([0-9]*).html userview.php?user=$1

    #contactus
    RewriteRule ^contactus.html contactus.php

    #legal
    RewriteRule ^legal.html legal.php

    #listingsearch
    RewriteRule ^listingsearch.html listingsearch.php

    #rentalsearch
    RewriteRule ^rentalsearch.html rentalsearch.php

    #viewusers
    RewriteRule ^view_users.html view_users.php

    #viewimage
    RewriteRule ^viewimage.html viewimage.php
    RewriteRule ^viewlistingimage-([0-9]*).html viewimage.php?imageID=$1&type=listing


    Al
     
    awddesign, Oct 4, 2004 IP
  10. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #10
    This works: RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1&rewrite=yes [NC,L]

    This doesn't work: RewriteRule ^listingview/([0-9]+)/?$ listingview.php?listingID=$1&rewrite=yes [NC,L]

    Thank You!
     
    ResaleBroker, Oct 4, 2004 IP
  11. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #11
    I have this already in my htaccess file as: php_value session.use_trans_sid 0. I'm assuming the <IfModule...etc aren't necessary, right?

    My program is working fine right now. Is this something I should also check? What are these for? They look like something I would find in the php info file but I didn't find them there.
     
    ResaleBroker, Oct 4, 2004 IP
  12. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi

    ""I have this already in my htaccess file as: php_value session.use_trans_sid 0.""

    this code is so the sessions do not show up .

    ""#php.ini configuration
    <IfModule mod_php4.c>
    php_value session.use_trans_sid 0
    </IfModule>""

    this is for if your php.ini does not have it or your cpanel is not setup.

    post the link to your site i will check it out for you.

    Al
     
    awddesign, Oct 5, 2004 IP
  13. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #13
    ResaleBroker, Oct 6, 2004 IP
  14. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #14
    Hi Al,
    I saw this over at the OP forum.

    Should I be using this too?

    setcookie("int", 123, time()+86400*365);
    if ($HTTP_COOKIE_VARS[int] == 123)
    {
    session_start();
    }
    else if ($_COOKIE[int] == 123) //you can change this but it depends on which version of PHP you have installed as to which one works.
    {
    session_start();
    }
    session_register("session");
     
    ResaleBroker, Oct 7, 2004 IP
  15. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Hi

    I not sure what you would want to do with that

    Let me know
    Al
     
    awddesign, Oct 9, 2004 IP
  16. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Hi
    Of topic :

    would you like to add 360 vertual tours to your site ?
    Let me know, i can set up a demo area for you.

    Al
     
    awddesign, Oct 9, 2004 IP
  17. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #17
    I just want to make sure there are no Session IDs.
     
    ResaleBroker, Oct 9, 2004 IP
  18. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Hi

    Just add this to the .htaccess file

    #
    php_value session.use_trans_sid 0
    #

    I think thats what does the trick

    Al
     
    awddesign, Oct 12, 2004 IP
  19. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #19
    Sound great. Thanks!
     
    ResaleBroker, Oct 13, 2004 IP
  20. awddesign

    awddesign Guest

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Hi Jeffrey

    I have just looked at your site now with the new
    htaccess file, the listings are great.

    Will have to do this with all OR's I use

    Al
     
    awddesign, Dec 27, 2004 IP