I've been looking into mod_rewrite for my simple PHP CMS for a couple of days now and I found a rule that was supposed to work for me:
RewriteRule ^(\w+)/?$ view_post.php?url=$1
This is supposed to take www.domain.com/example-post to the view_post.php page and query the post from a DB. This doesn't work if there are "-" dashes in the name. However, if I try www.domain.com/examplepost, it will work as I can see the view_posts.php page loading and the SQL being constructed correctly, however no content loads because obviously that won't match anything in the DB.
I could go a couple of ways around this, one would be to try to query the DB with both dashes and without, easily removed from the text with substr, however I would like for that rewrite rule to work with dashes as well for now. This is probably something related to the regexp, however it is beyond my comprehension.
Any help will be much appreciated!