在工作中,我们有一个 ViewVC 系统,它已从一台机器迁移到另一台机器。版本也升级了。旧系统用作/cgi-bin/viewvc.cgi
其所有 url 的基础,新系统使用/viewvc
. 主机名保持不变。
我们有很多包含 ViewVC 链接的文档,我希望它们仍然像以前一样工作。我白天是一名软件开发人员,所以不是 apache 专家,但我认为那mod_rewrite
是正确的途径。不幸的是,我似乎无法让它做我想做的事。
没有任何更改,当我转到 url 时,/cgi-bin/viewvc.cgi
我得到一个 404。这是我在 apache 日志中看到的内容:
==> /var/log/httpd/error_log <==
[Thu May 31 03:13:10 2012] [error] [client 172.16.3.52] script not found or unable to stat: /var/www/cgi-bin/viewvc.cgi
==> /var/log/httpd/access_log <==
172.16.3.52 - - [31/May/2012:03:13:10 +0100] "GET /cgi-bin/viewvc.cgi HTTP/1.1" 404 289 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.17 Safari/536.11"
当我将RewriteEngine
/RewriteRule
条目添加到/etc/httpd/httpd.conf
如下...
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
RewriteEngine on
RewriteRule ^/cgi-bin/viewvc.cgi(.*) /viewvc$1
</Directory>
我得到一个 403。这是日志中的内容:
==> /var/log/httpd/error_log <==
[Thu May 31 03:15:35 2012] [error] [client 172.16.3.52] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/cgi-bin/viewvc.cgi
==> /var/log/httpd/access_log <==
172.16.3.52 - - [31/May/2012:03:15:35 +0100] "GET /cgi-bin/viewvc.cgi HTTP/1.1" 403 293 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.17 Safari/536.11"
如果我编辑上面的选项行以包含FollowSymLinks
并且SymLinksIfOwnerMatch
我回到 404。
==> /var/log/httpd/error_log <==
[Thu May 31 03:17:20 2012] [error] [client 172.16.3.52] script not found or unable to stat: /var/www/cgi-bin/viewvc.cgi
==> /var/log/httpd/access_log <==
172.16.3.52 - - [31/May/2012:03:17:20 +0100] "GET /cgi-bin/viewvc.cgi HTTP/1.1" 404 289 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.17 Safari/536.11"
我究竟做错了什么?我的规则是错的还是放错了地方?mod_rewrite
甚至他是正确的做法吗?
版本:如果它很重要,我在 Fedora 17 机器上使用以下软件包:
- httpd-2.2.22-4.fc17.x86_64
- viewvc-1.1.13-2.fc17.noarch
- viewvc-httpd-wsgi-1.1.13-2.fc17.noarch