利用Apache 的 Rewrite 技术将 PHPwind 的页面地址转化为HTML地址

转自 www.feelone.net
就是用 Apache Rewrite的 技术
把你的PHP的动态页面映射成HTML的静态页面,这个HTML页面是不存在的,只不过当访问1.HTML的时候,服务器就会把1.HTML映射到1.PHP上!
Rewrite 很简单的说,就是把类似
==> /phpbb2/viewtopic.php?t=1388&start=0
动态网页,转成
==> /phpbb2/viewtopic-1388-0.html
好处有:
1. URL 短一点,静态网址的接受度较高。
2. Search Engine 比较吃的下去~
3. 静态的网址会有比较好的 SE-BENCHMARK

首先要看看你的空间是否支持REWRITE
看看探针就可以了! http://www.feelone.net/iprober.php?act=phpinfo

url_rewriter.tags a=href,area=href,frame=src,form=,fieldset= a=href,area=href,frame=src,form=,fieldset=
如果有的话
恭喜
请继续跟我来
写一个
.htaccess
文件
内容是:
RewriteEngine on
RewriteRule k([0-9]+).html $ read.php?tid= $1
RewriteRule k([0-9]+).html $ read.php?tid= $1&fpage= $2
RewriteRule t([0-9]+).html $ thread.php?fid= $1
RewriteRule p([0-9]+).html $ post.php?fid= $1
RewriteRule p1([0-9]+).html $ post.php?action=vote&fid= $1
RewriteRule index.html $ index.php
RewriteRule iprober.html $ iprober.php
只针对PHPWIND
其他的PHP地址请自己写
这样就已经被映射好了
解释一下,第一个是你的版块地址
第二个是你的帖子地址!
明白了吗?
不明白?
再看,还不明白?还看^^^
测试一下!
www.feelone.net/index.php
www.feelone.net/index.html

http://www.feelone.net/t40.html
http://www.feelone.net/thread.php?fid=40&page=

http://www.feelone.net/k7423.html
http://www.feelone.net/read.php?tid=7423

然后就是修改你的PHPWIND连接了
主要是摸板,很容易啊!
比如说index.html
在TEMPLATE/WIND

然后把

1<a href="thread.php?fid= $forums[fid]" target="_blank"><img border="0" src=" $imgpath/ $stylepath/ $forums[pic].gif"/></a>

替换成

1<a href="t $forums[fid].html" target="_blank"><img border="0" src=" $imgpath/ $stylepath/ $forums[pic].gif"/></a>
1<a href="thread.php?fid= $forums[fid]" target="_blank"> $forums[llogo]</a>
 1<a class="fnamecolor" href="thread.php?fid= $forums[fid]">
 2<a href="t $forums[fid].html" target="_blank"> $forums[llogo]</a>
 3<a class="fnamecolor" href="t $forums[fid].html">   
 4  
 5然后你的首页就已经可以了   
 6其他的自己研究一下吧!   
 7连你发帖子的地址也可以改!   
 8努力啊!   
 9如果实在不会做的话大家回帖子我把我的公布出来!   
10给大家直接下载吧!</a></a>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus