views:

87

answers:

1

I'm sorry for complexive question. I've got a website that reading contents from MySQL database to get video information just like YouTube.

I've 7 column: id, title, desc, url, date, whosadded, views.

I want to do is Rewriting url's from /video.php?id=X to /title-music-video.html

There's ( http://www.devarticles.com/c/a/Apache/Using-ForceType-For-Nicer-Page-URLs/1/ ) an article for that but htaccess's ForceType doesn't works for me.

I know there's a way adding new column to table for the optimized link but i dont want to specify every seo url when adding new records with form.

I'm stucked at this point, I need your help, thank you! btw... sorry for bad english...

+1  A: 

Did you read the whole article? ForceType doesn't magically convert URLs for you... it just forces the file to be served as certain type -- thus your .HTML URL can be interpreted as PHP.

Are your videos stored in the database? And your using the ID to pull them up? In that case, what you can do is add an extra column to the table, typically called "slug" and store in it the value of "artist-song-music-video" -- this column must be unique. If you think you might have two pages with that same name, use both the ID and the slug in the URL (like how this site does it -- videos/5/artist-song-music-video for example).

Then, what you actually do is rewrite the url -- /artist-song-music-video.html to /video.php?page=artist-song-music-video or something like that. Then in your index.php you typically have a "router" which takes $_GET['page'], looks up that slug in the DB, and displays the correct content.

I don't remember the exact mod_rewrite rule for translating URLs like that, but there are dozens of tutorials on the net. Google it.


Occured to me that artist and song might be variables. In that case, replace "slug" with your two presumably existing columns "artist" and "song" and look it up that way. Just hack off that "-music-video.html" part. I really don't know what your plan is, so I can't say more.

Mark
I edited my question.
Ronnie Chester Lynwood
"I know there's a way adding new column to table for the optimized link but i dont want to specify every seo url when adding new records with form" -- but they *do* submit the title? If so, just convert the title into a slug; that's the way you should be doing it anyway. They don't need to type anything. Just convert to lowercase and replace spaces wish dashes.
Mark