How would I rewrite ( for every posts in my blog ):
http://localhost/post.php?id=13
to
http://localhost/this-is-the-title-of-the-post/13
AND ( without id )
http://localhost/post.php?id=13
to
http://localhost/this-is-the-title-of-the-post/
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this rule:
This will rewrite a requested URI path like
/this-is-the-title-of-the-post/13internally to/post.php?id=13; so it’s rather the other way round of what you described. But that’s how mod_rewrite works: You can only change incoming requests and not outgoing responses.Now if you want to omit the numeric ID, your title needs to be the new ID:
That means it needs to be unique. Otherwise the title cannot be mapped onto the numeric ID unambiguously. In that case the title it would certainly be easier if you pass the title to post.php:
Obviously, since the title is unique, you don’t need the numeric ID any more.