+ -
当前位置:首页 → 问答吧 → windows xp + apache 2.2.15,开启mod_rewrite无效

windows xp + apache 2.2.15,开启mod_rewrite无效

时间:2010-09-26

来源:互联网

mod_rewrite问题,没有使用.htaccess,直接在httpd.conf中配置

mod_rewrite问题用URL:localhost/test.html为什么不能重定向呢??

httpd.conf修改如下

LoadModule rewrite_module modules/mod_rewrite.so

<IfModule mod_Rewrite.c>
  RewriteEngine on  
  RewriteRule ^/test.html$ /index.html
</IfModule>

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

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
  Options Indexes FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

现象如下:
在浏览器中输入:http://localhost/test.html,提示HTTP404未找到
apache access.log:0 127.0.0.1 [2010/09/26 11:06:57] "GET /test.html HTTP/1.1" 404 558 457 179

在浏览器中输入:http://localhost/index.html,能正确显示“Apache is success!”

在网上找过很多方法,都大同小异,拜请专家出马!

作者: x_todoo   发布时间: 2010-09-26


我估计你配置应该没错,是重定向url格式错了

在http.conf最后边加入这段代码看看:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)/([a-z]+)/([a-z]+).html$ $1/$2/$3.jsp [PT]
RewriteRule ^(.*)/([a-z+]).html$ http://www.baidu.com [L]

</IfModule>

先找上边的配置试试,输入个a.html 看看是不是定向到了百度页面

作者: liujun5515008   发布时间: 2010-09-26