SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    another mod rewrite question...

    ive spent ages and ages on the net trying to get this work and tons of topics on this board. i came across a article which had exactly what i wanted. all i had to do was upload a 4/5 line htaccess file (Unfortunately it didnt work ), everything else ive seen requires lines and lines!


    Anyways this is what i wanted to do..

    i have a site where i have the following (examples;have various product items /categories etc...)

    http://www.mysite.co.uk/category.php?n=12 ( category)
    http://www.mysite.co.uk/ware.php?id=520 (product)
    http://www.mysite.co.uk/scategory.php?n=22 (subcategory)


    i would like to ( suprise suprise) make them into normal urls

    something like www.mysite.co.uk/product/520
    etc


    Help will be really really apperciated.

    Thank you.

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chetas
    ive spent ages and ages on the net trying to get this work and tons of topics on this board. i came across a article which had exactly what i wanted. all i had to do was upload a 4/5 line htaccess file (Unfortunately it didnt work ), everything else ive seen requires lines and lines!


    Anyways this is what i wanted to do..

    i have a site where i have the following (examples;have various product items /categories etc...)

    http://www.mysite.co.uk/category.php?n=12 ( category)
    http://www.mysite.co.uk/ware.php?id=520 (product)
    http://www.mysite.co.uk/scategory.php?n=22 (subcategory)


    i would like to ( suprise suprise) make them into normal urls

    something like www.mysite.co.uk/product/520
    etc


    Help will be really really apperciated.

    Thank you.
    Hi,

    something like this ?

    /.htaccess
    Code:
    RewriteEngine On
    
    RewriteRule ^product/([0-9]+)/?$ /ware.php?id=$1 [L]
    RewriteRule ^subcategory/([0-9]+)/?$ /subcategory.php?id=$1 [L]
    RewriteRule ^category/([0-9]+)/?$ /category.php?id=$1 [L]

    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi so all i do is paste that into a text file upload it, call it .htaccess and it should work?

    ps thanks for the quick reply! im impressed

  4. #4
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  5. #5
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i pasted it and well the site seem to be working as normal- cant see no difference in the urls. did i make a mistake?

  6. #6
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should try:
    example.com/product/110
    and it should go, internally, to
    example.com/ware.php?id=110

    Remember that mod_rewrite can ``translate'' requests.
    It cannot convert dynamic links from the html generated by your php scripts.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  7. #7
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pippo
    You should try:
    example.com/product/110
    and it should go, internally, to
    example.com/ware.php?id=110

    Remember that mod_rewrite can ``translate'' requests.
    It cannot convert dynamic links from the html generated by your php scripts.

    oh ok. woohooo it works except now my cart dont work and the images are all coming up as dead links as they are looking them in product/


    How would i force the cart system to write the dynamic url as normal ones. as i have a custom cart, i suppose its not as simple

  8. #8
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I worked with a client that had cart system him too.
    Basically writing mod_rewrite, my job, is one part of the task,
    the remain task is to generate html containing static urls.
    In his case he had to change manually some links in some pages as:

    from
    <a href="%%script_loc%%?user_action=category&category=%%urlcategory%%">%%category%%</a>

    to
    <a href="category/%%urlcategory%%">%%category%%</a>

    Sometimes it could not be so that easy...

    About broken images, yep that client had them too, is more probably due to the usage of relative links for images.
    You should use absolute images links.

    Because originally you had:
    example.com/ware.php?id=110
    <img src="images/pippo.gif">
    so the browser would have asked
    example.com/images/pippo.gif

    but with static urls you have
    example.com/product/110
    <img src="images/pippo.gif">
    so the browser will ask
    example.com/product/images/pippo.gif

    using an absolute path you will be fine
    <img src="/images/pippo.gif">
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  9. #9
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vc

  10. #10
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im back. ive rewritten all the links as direct urls.

    but now i got this problem
    http://www.mysite.co.uk/product/520?...02130873299b18

    which means after all my hard effort, google still aint spidering. HELP PLEASE!!!!!!

  11. #11
    l 0 l silver trophybronze trophy lo0ol's Avatar
    Join Date
    Aug 2002
    Location
    Palo Alto
    Posts
    5,329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what software you're using, but you'd obviously need to find a way to turn off session ID's. You could also write some scripting where if Googlebot is visiting your page, turn off session ID's just for that. It all depends on what you're running though.

  12. #12
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi lo0ol [] , its a custom developed cart.

    i think turning off sessions will mean a total rewrite of the cart system :S ot would it be simple?

    what would scripting involve.. i suppose i would need it for goggle, yahoo etc...

  13. #13
    SitePoint Member
    Join Date
    Jan 2004
    Location
    London
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone else?


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
  •