SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Location
    San Diego
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite question

    Does anyone know the mod_rewrite rule to redirect the user's input of
    http://www.whatever.com/page/10.html
    to
    http://www.whatever.com/page.php?id=10
    ?

    And anyone have some resources on mod_rewrite in general? Thanks
    Kyle Maxwell
    www.kylemaxwell.com

  2. #2
    The short answer is yes... Herbster's Avatar
    Join Date
    Oct 2001
    Location
    Bay City, Oregon
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^/page/([0-9]+).html$ page.php?id=$1 [NC]

    Something like this should work. I've probably screwed up a detail or two, but that will give you something to do - lol.

  3. #3
    SitePoint Zealot oivaf's Avatar
    Join Date
    Apr 2003
    Location
    Mexico
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    some resources for mod_rewrite

    here are some of the resources of mod_rewrite

    the official mod rewrite docs http://httpd.apache.org/docs/mod/mod_rewrite.html

    the mod rewrite guide by its creator http://www.engelschall.com/pw/apache/rewriteguide/

    From www.alistapart.com
    how to map everything (except images, css, etc.) to index.php
    http://www.alistapart.com/stories/succeed/

    how to deal with some specific mappings
    http://www.alistapart.com/stories/urls/

    basically it's all about regular expressions

  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)
    Quote Originally Posted by Herbster
    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^/page/([0-9]+).html$ page.php?id=$1 [NC]

    Something like this should work. I've probably screwed up a detail or two, but that will give you something to do - lol. [img]images/smilies/tongue.gif[/img]
    Hi,
    yes some details are missing ;-).

    I'd use into an .htaccess placed into your document root:
    Code:
    Options +FollowSymLinks
    RewriteEngine on 
    RewriteRule ^page/([0-9]+)\.html$ page.php?id=$1
    Herbster, if you are writing a rewrite rule that will go inside an .htaccess you can't write RewriteRule ^/page..., but you have to write RewriteRule ^page...
    That's because it's a directory context, so if you request www_somesite_com/page/10.html then the URI that RewriteRule will compare to is page/10.html and NOT /page/10.html ( that's the REQUEST_URI ). :-)



    Thank you,
    :-) Andrea

    p.s.
    Check my sig if you want to put some Apache related further questions ;-)
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


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
  •