rewrite rule for this url?

Discussion in 'Apache' started by greatlogix, Jul 2, 2009.

  1. #1
    What is the rule to rewrite following url

    www.example.com/news/article.php?title=title-here&id=3
    to
    www.example.com/news/title-here-3.htm
    Code (markup):
    Any help?
     
    greatlogix, Jul 2, 2009 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine On
    RewriteRule ^news/article.php?title=([a-z0-9_-]+)&id=([0-9]+)$ news/$1-$2
    Code (markup):

    Try that! :)
     
    Wrighty, Jul 2, 2009 IP
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    Thanks Wrighty for your reply.
    I tried this but its not working
    
    
    Here is the dynamic url
    http://www.example.com/news/article.php?title=flip-has-little-chance-in-an-iphone-world&id=21
    
    I need it like this
    http://www.example.com/news/flip-has-little-chance-in-an-iphone-world-21.htm 
    
    
    Code (markup):
     
    greatlogix, Jul 3, 2009 IP
  4. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    RewriteEngine On
    RewriteRule ^news/([a-z0-9_-]+)-([0-9]{2})$ news/article.php?title=$1&id=$2
    Code (markup):
    Try that! :)
     
    Wrighty, Jul 3, 2009 IP