刚开始接触Apache Rewrite,现在问题多多,主要是rewrite效果根本就没实现过!!!另外.htaccess来设置也没成功过
1.打开LoadModule rewrite_module modules/mod_rewrite.so模块。
2.修改根目录AllowOverride。
<Directory "C:/apache2/htdocs">
 
    Options Indexes FollowSymLinks
# Options All 这样改了貌似也无效
    AllowOverride All
    Order allow,deny
    Allow from all</Directory>3.根目录下新建.htaccess文件,写入以下内容。(/code/sample2_1.html是实际存在的。)
RewriteEngine on
RewriteRule   ^/$  /code/sample2_1.html  [R]重启apache,打开http://localhost/并没有rewite的效果。4.打开Apache错误日志,发现以下内容:[Sat Jun 05 13:03:53 2010] [error] [client 127.0.0.1] client denied by server configuration: C:/apache2/htdocs/.htaccess5.怀疑与.htaccess访问权限有关系,于是注释掉http.conf的以下内容。
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>
重启apache,依然无法跳转,日志没有出现错误。6。再次怀疑.htaccess是否生效。
于是向.htaccess写一些垃圾信息 像~~~~~~
再次访问出现Internal Server Error,.htaccess看来是起效的。7.把以下内容写入http.conf中
RewriteEngine on
RewriteRule   ^/$  /code/sample2_1.html  [R]重启,输入http://localhost/转到http://localhost/code/sample2_1.html,但仅仅是跳转而已。地址栏显示的还是http://localhost/code/sample2_1.html,注意:不是直接显示 http://localhost/ !!8.只能怀疑是不是模块的问题.- _- !!! 环境是WindowsXP,apache是2.2.4版本的,rewrite模块是自带的。9.现在,只能四下求救了~,大家有没有遇到过这个问题,有的话,给小弟指点一二好吗?感激不尽~

解决方案 »

  1.   

    顺便说一下,那个是从Apache手册拿过来的。
      

  2.   

    RewriteLog "/usr/local/var/apache/logs/rewrite.log" 
    RewriteLogLevel 6看看日志上报什么的,贴出来分析.
    我怀疑是/code/sample2_1.html 有没有权限访问啊?
      

  3.   


    第7条的可以访问就证明是有权限的。自从改了.htaccess 的权限后,apache的日志没错误。
    rewrite的日志没设置过,试试,谢谢。