我已经搜索过,但是这里的所有例子都不适合我。修改Mod_rewrite规则,将文章标题添加到URL
I have a $_SESSION['title']; //Session variable contains title from calling page
$title = $_SESSION['title']; //local variable contains article title
比方说,文章的标题是新闻的最天 如何修改我的规则来
http://www.newstoday.com/readnews/12/news-of-the-day
BTW http://www.newstoday.com/readnews/12 //this works
RewriteEngine on
RewriteRule ^readnews/([0-9]+)$ readnews.php?news_art_id=$1
我该如何在html链接中使用此链接? –
这两个你的网址 http://www.newstoday.com/readnews/12/news-of-the-day http://www.newstoday.com/readnews/12 将重定向到readnews.php脚本,您可以从$ _GET ['news_art_id']和“$ news”(对于第二种情况是“”)从$ _GET ['other_params']获得“12” ; 从php生成这样的链接: $ id = 0; //假设这是你的编号 $ title = $ _SESSION ['title']; $ link ='http://www.newstoday.com/readnews/'。 $ id。 '/'。 $称号; –