![]() |
mod rewrite - how to get title in url?
Hey guys!
I have a php file names view_news.php. This PHP file gets the item id from the url and queries the news table in my DB to show the entry with that id. The table has a title column. How can I make a mod rewrite file so I can have my title as the url eg: mydomain.com/news/id-news-title-goes-here.html? I don't want to add each news item seperately into my htaccess file. How can I accomplish this and how can I get php to remove all weird symbols etc... from my url title? Looking forward to your answers! :) |
Hi Sam,
Try creating a new .htaccess file and adding the following code: Code:
<IfModule mod_rewrite.c>news/1-a.html but this would not: news/a-a.html Hope this helps. |
The htaccess file gives me a 500 server error. :(
|
Hey, I somehow managed to mess up the copy and paste, lol :)
here's the .htaccess file again: Code:
<IfModule mod_rewrite.c> |
Damn thanks! Works like a dream!
|
Quote:
Code:
# Original by Karl: RewriteRule ^news/([0-9]+)-([^\/]+).html$ news.php?id=$1 [L]
(Sorry for hijacking your thread with comments on Karl's code) |
| All times are GMT. The time now is 10:26 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0