Simple URL Rewriting

Discussion in 'Programming' started by MarcelB, Aug 28, 2008.

  1. #1
    Hi everybody ,

    i'am new to URL Rewriting
    i have a website with link like this

    http://www.mysite/comment.php?ID=31&Title=test-rewriting
    
    PHP:
    and want to make it appear like

    http://www.mysite/31-test-rewriting.html
    
    PHP:

    Thanks
     
    MarcelB, Aug 28, 2008 IP
  2. Joseph S

    Joseph S Well-Known Member

    Messages:
    1,373
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Why not google for "htaccess rewrite tool"? There are a lot of tools that can generate a rewritten URL in different formats.
     
    Joseph S, Aug 29, 2008 IP
  3. ChrisLomax

    ChrisLomax Peon

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you have had no luck with this then try

    ^([0-9]+)-([0-9a-zA-Z]+)\.html$

    So add this to your .htaccess

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^([0-9]+)-([0-9a-zA-Z]+)\.html$ comment.php?ID=$1&Title=$2[L, QSA]
     
    ChrisLomax, Sep 3, 2008 IP