Search code examples
phpmod-rewritedynamic-datablogsweb-standards

Dynamic mod_rewrite or how to plan a dynamic website


I'm trying to make a clean url for a blog on a dynamic website, but I think that the problem is that I don't know how to plan the website schema.

I read about how to use mod_rewrite and all I found is how to make "http://www.website.com/?category&date&post-title" to "http://www.website.com/category/date/post-title". that's works o.k for me.

The problem is that If my url looks like "http://www.website.com/blog/?id=34" this method won't work as far as I got it.

So, I have two questions: 1. Is there a way to use mod_rewrite (maybe read from a txt file) to read the post title of my blog and rewrite my url by date and post-title? 2. Should I rewrite my website to query the data from one index file in the homepage and use mod_rewrite to write the nice url? should I query also the date and the title of the post instead just the post ID?


Solution

    1. mod_rewrite used to rewrite requests and it has nothing to do with urls. You have to change urls by hands.
    2. yes, it's most common practice, to query the data from one index file
      no, you can't use mod_rewrite to write the nice url
      yes, an id must be present in the url along with title. your engine will just throw title away and use only id to retrieve an article.

    Take a look at SO urls for an example