Help with .htaccess file and url rewrite

Discussion in 'HTML & Website Design' started by niks00789, May 26, 2011.

  1. #1
    I have a php file, say xyz.php

    I pass a parameter to it saying id=xZeirE3s (which is variable)

    http://www.example.com/xyz.php?id=xZeirE3s
    Code (markup):
    Now i want to rewrite url in such a manner that when i enter a url like

    http://www.example.com/dynamic-title-of-page-xZeirE3s.html
    Code (markup):
    Then it just reads that end part i.e. xZeirE3s and opens the page

    http://www.example.com/xyz.php?id=xZeirE3s
    Code (markup):
    I know it wont be that difficult, but i'm really bad at making regular expressions and .htaccess files

    Thanks in advance. :)
     
    niks00789, May 26, 2011 IP
  2. TSelbeck

    TSelbeck Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine on
    RewriteRule ^([A-Za-z0-9_-]+)-([A-Za-z0-9_-]+).html$ xyz.php?title=$1&id=$2 [NC]
    Code (markup):
    Haven't tested it, but hope this helps.
     
    TSelbeck, May 27, 2011 IP
  3. niks00789

    niks00789 Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #3
    omg that was so easy! thanks a lot man! it worked :)
     
    niks00789, May 28, 2011 IP