Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Mod Rewrite Rule Questions

Options
  • 11-08-2014 3:24pm
    #1
    Registered Users Posts: 1,987 ✭✭✭


    Are you able to have two rules like below for the same 'directory' even though 'blog/' doesn't physically exist?

    So you'd have somethinig like http://localhost/blog/2014/ or http://localhost/blog/2014/32-this-is-a-url/
    RewriteRule ^blog/([0-9]+)/$ blog.php?year=$1 [L,NC,QSA]
    RewriteRule ^blog/([0-9]+)-([a-zA-Z-]+)/$ blog.php?id=$1&title=$2 [L,NC,QSA]
    

    Or is it better practise to use something like this:
    RewriteRule ^blog/([0-9]+)/$ blog.php?year=$1 [L,NC,QSA]
    RewriteRule ^blog/([0-9]+)/([0-9]+)-([a-zA-Z-]+)/$ blog.php?year=$1&id=$2&title=$3 [L,NC,QSA]
    


Advertisement