views:

140

answers:

3

While rewriting url in php from dynamic to static... suppose url story.php?id=12 is rewritten now when in story page i will read $_GET['id'] it will return null....

How to do this correctly?

+1  A: 

Make sure you're adding your parameters in your rewrite rule...

For example, if the new address was /Story/12/ instead of story.php?id=12 it would look like this:

RewriteRule ^Story/([^/\.]+)/?$ story.php?id=$1 [L,NC,QSA]
Sohnee
A: 

Um... how do your rewrite rules look? Is it possible that you misunderstood the point of URL rewriting?

The goal is usually to present "static" URLs to the user that get rewritten into GET parameters so you can use them in your scripts. It sounds like you're doing the opposite - but why?

As always, to get good answers for your question, you need to say exactly

  1. What you did
  2. What you expected to happen
  3. What happened instead
Michael Borgwardt
A: 

Does your rewrite check out? If not try using something like the one listed below:

RewriteRule    ^story/(.+)/$ story.php?id=$1 [QSA]
Sam152