伪静态html,Apache伪静态html(URL Rewrite)

Apache伪静态html(URL Rewrite)
Apache 的配置文件 httpd.conf
1,将#LoadModule rewrite_module modules/mod_rewrite前面的#去掉
2,将您的主机的中的AllowOverride None改为AllowOverride All
保存httpd.conf并重启Apache
.htaccess
在你的网站根目录下面新建
.htaccess
在里面写上
<IfModule mod_rewrite.c>
RewriteEngine _disibledevent=>
RewriteRule ^plan/detail-([0-9]+).html$ plan/index.php?m=detail&id=$1
</IfModule>
这样子如你的网站下面
plan/index.php?m=content
plan/cat-content.html
plan/index.php?m=detail&id=8
plan/detail-8.html
我写的一个函数转换
function rewrite_url($m,$id = '0'){
global $_S;
if($_S['site_rewrite']){
$url = ($m=='detail' && $id) ? "detail-".$id.".html" : "cat-".$m.".html" ;
}else
{
$url = $id ? "index.php?m=".$m."&id=".$id : "index.php?m=".$m;
}
echo $url;
}
连接地址调用
<a href="<?=rewrite_url('contact')?>">联系我们</a>
<a href="<?=rewrite_url('detail',$v['articleid'])?>">***文章</a>
Tags:  伪静态html

延伸阅读

最新评论

发表评论