thinkphp3 伪静态和url重写 多重匹配的简单设置
根据thinkphp3.0的手册url重写的那一节配置apache。
然后再网站根目录下放置.htaccess文件,内容如手册所提示的一样
win2003的空间iis6不支持.htaccess,尽可能选用linux系统的服务器
?
rewriteengine onrewritecond %{request_filename} !-drewritecond %{request_filename} !-frewriterule ^(.*)$ index.php/$1 [qsa,pt,l]转载请注明出处:http://tyllxx.iteye.com
??
虽然可以用url_html_suffix实现伪静态,但是这里的方法是使用.htaccess文件来实现。
以上代码可以实现让:
http://servername/index.php/blog/read/id/1
变为:
http://servername/blog/read/id/1
?
那么还要让其变为:
http://servername/blog/1.html
?
若还有:
http://servername/buy/1.html
http://servername/topic/diy.html
怎么实现呢?
?
以下是实现方法:(.html后缀,自己在写连接时自己加上,用url_html_suffix方式,去掉方法中的.html)
?
?
rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ index.php/$1 [qsa,pt] rewriterule ^(.*)/topic/(.*)\.html$ $1/topic/index/index/links/$2 [qsa,pt] rewriterule ^(.*)/buy/(.*)\.html$ $1/buy/index/index/id/$2 [qsa,pt,l]转载请注明出处:http://tyllxx.iteye.com
?此方法已经验证过,只需要修改匹配字段和替换字段即可使用。