php blog url rewrite;解决办法

WBOY
Release: 2016-06-13 12:32:20
Original
794 people have browsed it

php blog url rewrite;

本帖最后由 u010689324 于 2013-11-29 22:46:22 编辑 各位前辈,本人初学php,想写个简单的博客(以学习php为主,没有用wordpress)。目前遇到的问题是:
博客首页(http://www.mysite.com)展示了所有博文的一些信息(标题、内容的前两段、标签、日期等),希望在点击标题后跳转到该文章的阅读页面,或是点击标签后跳转到显示该标签对应的所有文章的页面。但是不想在url中以 http://www.mysite.com/blog.php?postid=100这样的形式来跳转,希望能像wordpress那样实现http://www.mysite.com/blog/100这样的url。(我的设想是在blog.php里根据点击的跳转地址来动态显示相应信息,如设置文章标题为

title

,点击后跳转到blog.php,在这里获得文章的id 100,然后查询数据库来显示,点击标签则显示相应的信息)。这是通过配置服务器的rewrite规则来实现吗?还是像wordpress那样也结合php程序来解析?或是其他的。哪种方式更高效和不那么麻烦?如果能解决这个问题,我打算采用smarty模板引擎来显示首页的文章信息:
{foreach $articles as $article} 

  
  

{/foreach}
其中$aritlces是一个包含所有文章显示信息的数组,举例为:
while(has_post()){
$articles[] = array(
 'posted_date' => $posted_date,
 'tags'=>array($tag1,..$tagn),
 'id'=>$post_id,
 'title'=>$title,
 'content'=>$content
);
}
(这里只是举例说明$articles包含的数组类型,当然实现代码不会是这样)
请问各位,我这种方法能实现所想要的吗?
如果可以实现,还望指教!在此谢过!!
php url?rewrite 博客设计 url重写
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!