于是google,找到解决方案。原来是Apache的rewrite目录权限问题。
那么,让我们来看看如何配置rewrite:
1.打开Apache的配置文件——http.confvi /etc/apache2/extra/httpd-vhost.conf
LoadModule rewrite_module modules/mod_rewrite.so
2.执行a2enmod rewrite
,显示ok则正确。
3.vi /etc/apache2/sites-enabled/000-default
,找到网站节点的那一行
将其中的:AllowOverride None
,修改为:AllowOverride All
。
4.重启/etc/init.d/apache2 restart
验证方法:
1.在网站根目录创建.htaccess文件,内容如下:
RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html
该文件的作用在于把文件的后缀名.html .htm等改成.php,这样我们就可以在html文件里写一个简单的php程序,看看能不能显示php的运行结果。
2.
<?php echo "Yes, This is a test."; ?>
保存为a.html,同样放置在根目录下。
3.我们键入地址,比如http://localhost/a.html,看是否能出现"Yes, This is a test ", 如果能则我们所做的修改时成功的,如果显示空白,则没有成功,请检查刚才所做的步骤,或者是查找其他的原因。