1、 服务器开启url_rewrite功能,linux空间的php虚拟主机只需要开启apache的mod_rewriet,如果是iis6.0就要安装ISAPI Rewrite模块,apache只要开启Mod_rewrite功能就可以了。无忧主机linux系统的空间,开通空间默认支持。

2、 Linux空间编辑.htaccess文件,windows空间编辑httpd.ini文件。

thinkphp如何编写.htaccess文件?

无忧主机(www.51php.com)编写的thinkphp伪静态正则表达式.htaccess文件如下:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

请将上面正则表达式,保存为.htaccesss文件,并放到thinkphp项目入口文件同级目录下。并且修改数据库配置(config.php)文件使网站支持url重写功能,加入代码:define(‘URL_REWRITE’,2);

例子:$this->buildHtml('1', HTML_PATH . '/home/', 'yemian', 'utf8');
$this->display();
posted on 2016-08-26 15:55  飘渺的悠远  阅读(1419)  评论(0编辑  收藏  举报