欢迎您来到,码代码-小马博客        登录  |  注册

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

更新:2015-10-19 08:28:40
人气:6494
来源:本站原创
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规则已经启用。

打赏

取消

感谢您的支持,我会继续努力的!

扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

推荐的文章
# 发表我的评论
  /     /  
# 最近评论
暂时还没有评论,要不要说点什么?
  积分活动
  关注分享
  联系博主
QQ:1510489656   个人微信号:xkqp007
网站地图
会员服务
关于我们
QQ:1510489656
 
广告服务
加我微信
移动端访问
 
 
Copyright © 2014-2024 www.dizhix.cc All Rights Reserved.
技术支持:PHP博客系统,由小马博客 www.dizhix.cc 开发并免费开源分享   ICP备案号:鄂ICP备2022012090号-1