tags:

views:

70

answers:

4

i have one blog where users come and post their views. i store all information in mysql Data Base, when i use following syntax to retrieve information Datasbe using PHP

viewpost.php?pid=12

but after Google many tips for SEO, i found that this syntax is not good, i need to change it to some other way which is readable to search engine.

exactly like stackoverflow.com does. like every question have its url like

   http://stackoverflow.com/questions/1696938/c-objects-by-ref

i search all day but did't get any idea how can i do something like this in PHP & MYSQL

Hope i will get good help.

Thanks

A: 

You usually use Apache's mod_rewrite (other webservers have similar functions) to accomplish this. Read more about mod_rewrite here: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Using mod_rewrite /questions/1696938/c-objects-by-ref gets rewritten to (as an example) questions.php?id=1696938. The c-objects-by-ref part is probably there only to make the url more readable to humans, and look nicer to search engines.

In your case I would rewrite /post/$id/human-readable-name to /viewpost.php?pid=$id

adamse
Don’t forget to check if the slug is correct. Otherwise that can spoofed.
Gumbo
A: 

you have to rewrite your urls

so that domain.com/12/title-of-post goes to domain.com/viewpost.php?pid=12

try this page for more in depth information

Galen
i did't get your link...
air
A: 

Here is a good tutorial

Shadi Almosri
this article is good, but i am working under IIS and PHP, look i am sorry but i can't figure out how to do it...?
air
+1  A: 

If you're on IIS try this

http://www.codeplex.com/IIRF

it's a free url rewriter for IIS

Galen