欢迎您来到,李雷博客 | PHP博客        登录  |  注册

如何启用Apache服务器的rewrite和.htaccess功能

更新:2015-10-19 08:28:40
人气:6746
来源:本站原创
A+

大家在使用Appserv服务器伪静态规则时,会利用.htaccess文件,但是如果当你打开网站,第一眼看到如下信息:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. 


Apache/2.2.8 (Win32) PHP/5.2.6 Server at www.mdaima.cn Port 80

这说明你的服务器并没有开启.htaccess文件支持功能,那么如何开户这个功能呢?

第一步,httpd.conf 文件里 查找“<Directory />”把里面的 AllowOverride None 改成 AllowOverride all 即可,改完后的代码如下: 

<Directory />
       Options FollowSymLinks
       AllowOverride all
       Order deny,allow
       allow from all
</Directory>

第二步,查看一下你的phpinfo(),如果在apache2handler的Loaded Modules 中找到了mod_rewrite 那么说明你的rewrite module已经加载了。如果没有开启“mod_rewrite”,则打开您的apache安装目录“/apache/conf/”下的 httpd.conf 文件,通过Ctrl+F查找到“LoadModule rewrite_module”,将前面的"#"号删除即可;如果没有查找到,则到“LoadModule”区域,在最后一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(独占一行)。

到这里重启apache服务,URL重写rewrite规则已经启用。

推荐的文章
# 发表我的评论
  /     /  
# 最近评论
暂时还没有评论,要不要说点什么?
  Ads by Google
  联系博主
Hello,本博客系统采用PHP和MySql开发,程序开发完全是因为个人爱好,是自己纯手写PHP源代码,未采用任何PHP框架!
QQ:858353007   微信号:lileihot123
网站地图
会员服务
关于我们
QQ:858353007
 
广告服务
加我微信
移动端访问
 
 
Copyright © 2014- 2024 www.mdaima.com All Rights Reserved.
李雷博客,专注PHP经验、PHP教程及PHP源代码开源下载分享的PHP博客!   ICP备案号:京ICP备10202169号-4