I’m sorry for complex question. I’ve got a website that reading contents from MySQL database to get video information just like YouTube.
I’ve 7 columns: id, title, desc, url, date, whosadded, views.
What I want to do is to Rewrite the 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 don’t want to specify every seo url when adding new records with a form.
I’m stuck at this point.
Did you read the whole article?
ForceTypedoesn’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-videofor example).Then, what you actually do is rewrite the url —
/artist-song-music-video.htmlto/video.php?page=artist-song-music-videoor something like that. Then in yourindex.phpyou 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_rewriterule for translating URLs like that, but there are dozens of tutorials on the net. Google it.Occured to me that
artistandsongmight 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.