Home  >  Article  >  Backend Development  >  thinkphp中什么是伪静态?

thinkphp中什么是伪静态?

PHPz
PHPzOriginal
2016-06-13 11:45:192697browse

thinkphp中什么是伪静态?

什么是伪静态?

简单说就是将动态的url变成静态的url显示,就叫做伪静态。“伪”就是假的,不是真的静态url,是通过技术手段实现的。

伪静态技术是指展示出来的是以html一类的静态页面形式,但其实是用ASP一类的动态脚本来处理的。

用户只要开通无忧php虚拟空间就支持url重写功能,无需其它任何设置,我们使用伪静态的好处,就是可以优化网络引擎,提高网站权重。将网站静态化处理,是网站seo优化非常重要的一个工作。

Thinkphp也可以通过技术手段,实现伪静态处理。

满足thinkphp伪静态(url重写)条件:

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

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

thinkphp如何编写.htaccess文件?

编写的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);  

更多相关知识,请访问 PHP中文网!!

Statement:
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