apache中mod_rewrite仅当配在虚机里时有效的问题
Posted on 八月 26th, 2007 由 哈哈
今天在apache(httpd2.0.x)上配mod_rewrite
发现一个问题:
我本来是在/etc/httpd/conf.d/目录下单建的个文件来保存mod_rewrite的配置的
但奇怪的是在这里面的rewrite的设置并没有生效
琢磨了半天
把rewrite的设置写进相应的VirtualHost里
再重启apache
居然生效了!!!
于是就有个困惑:为什么mod_rewrite的设置要写进<VirtualHost>里才会生效呢
终于,在apache的官方文档里看到关于RewriteEngine的一句话:
Note that, by default, rewrite configurations are not inherited. This means that you need to have a RewriteEngine on directive for each virtual host in which you wish to use it.
这样好像模模糊糊的解释了我的困惑
因为RewriteEngine在每个VirtualHost里缺省都是关掉的
那么当访问来的时候,写在VirtualHost外面的mod_rewrite的设置自然是看不到效果的





Discussion Area - Leave a Comment