1

我正在尝试重写:repo.pointfree.net/darcsweb/darcsweb.cgi?r=remixbot;a=summary

例如repo.pointfree.net/remixbot/summary/

...但是 url 显然没有被重写(当我访问 repo.pointfree.net 时,我得到了Error 403 Forbidden)。这是我.htaccess/home/public/werc/sites/repo.pointfree.net

DirectoryIndex darcsweb/darcsweb.cgi
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule ^/darcsweb/darcsweb.cgi /darcsweb/%1/%2?

这是.htaccess/home/public/

Options +ExecCGI
AddHandler cgi-script .cgi
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} !^repo\.pointfree\.net$
RewriteRule (.*) /home/public/werc/sites/%{HTTP_HOST}/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /home/public/werc/bin/werc.cgi

RewriteRule /werc.cgi /f5/pointfree/public/werc/bin/werc.cgi
ErrorDocument 404 /werc.cgi

我在 /home/public/werc/sites/repo.pointfree.net/ 中有一个符号链接到 /home/public/darcsweb,名为 darcsweb

对此的任何帮助将不胜感激。

谢谢, 安德烈亚斯

编辑,在应用 Andreas Gohr 的建议并访问 repo.pointfree.net/remixbox/summary/ 之后,我在我的日志文件和浏览器中的 404 页面中得到了这个。

[Mon Feb 21 00:15:28 2011] [error] [client 172.17.0.144] NOT FOUND: repo.pointfree.net/favicon.ico - http://repo.pointfree.net/remixbot/summary/ - Uzbl (Webkit 1.2) (Linux i686 [i686]), referer: http://repo.pointfree.net/remixbot/summary/
[Mon Feb 21 00:15:28 2011] [error] [client 172.17.0.144] repo.pointfree.net/favicon.ico - Uzbl (Webkit 1.2) (Linux i686 [i686]) - GET - tpl_handler lib/404.tpl - lib/default_master.tpl, referer: http://repo.pointfree.net/remixbot/summary/

当我将 favicon.ico 复制到 /home/public/ 时,我得到:

[Mon Feb 21 00:17:46 2011] [error] [client 172.17.0.131] NOT FOUND: repo.pointfree.net/remixbot/summary/ -  - Uzbl (Webkit 1.2) (Linux i686 [i686])
[Mon Feb 21 00:17:47 2011] [error] [client 172.17.0.131] repo.pointfree.net/remixbot/summary/ - Uzbl (Webkit 1.2) (Linux i686 [i686]) - GET - tpl_handler lib/404.tpl - lib/default_master.tpl

我还查看了 rewrite_log 的输出,没有提到 darcsweb(短路?):

172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] strip document_root prefix: /f5/pointfree/public/werc/bin/werc.cgi -> /werc/bin/werc.cgi
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (1) [perdir /f5/pointfree/public/] internal redirect with /werc/bin/werc.cgi [INTERNAL REDIRECT]
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] rewrite 'index.cgi' -> '/home/public/werc/bin/werc.cgi'
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] rewrite '/home/public/werc/bin/werc.cgi' -> '/f5/pointfree/public/werc/bin/werc.cgi'
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] strip document_root prefix: /f5/pointfree/public/werc/bin/werc.cgi -> /werc/bin/werc.cgi
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (1) [perdir /f5/pointfree/public/] internal redirect with /werc/bin/werc.cgi [INTERNAL REDIRECT]
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] rewrite 'index.pl' -> '/home/public/werc/bin/werc.cgi'
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] rewrite '/home/public/werc/bin/werc.cgi' -> '/f5/pointfree/public/werc/bin/werc.cgi'
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (2) [perdir /f5/pointfree/public/] strip document_root prefix: /f5/pointfree/public/werc/bin/werc.cgi -> /werc/bin/werc.cgi
172.17.0.131 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a43a058/subreq] (1) [perdir /f5/pointfree/public/] internal redirect with /werc/bin/werc.cgi [INTERNAL REDIRECT]
172.17.0.132 - - [21/Feb/2011:03:49:13 +0000] [repo.pointfree.net/sid#286c26a0][rid#2a5f0058/initial] (1) [perdir /f5/pointfree/public/] pass through /f5/pointfree/public/favicon.ico
4

2 回答 2

1

为什么在你的 URL 中它应该是一个 & 符号的地方有一个分号?

repo.pointfree.net/darcsweb/darcsweb.cgi?r=remixbot;a=summary

以上不应该是

repo.pointfree.net/darcsweb/darcsweb.cgi?r=remixbot&a=summary

另外,这个 RewriteRule 怎么样?

RewriteRule ^darcsweb/darcsweb.cgi?r=(.+)&a=(.+)$ /$1/$2/

作为调试帮助,请通过删除 RewriteCond 尝试一次,以确保它没有任何问题。

于 2011-02-20T21:43:32.597 回答
1

在我看来,您以错误的方式进行了重写。如果我理解正确,您希望能够使用像 repo.pointfree.net/remixbot/summary/ 这样的 URL 来访问真正的 repo.pointfree.net/darcsweb/darcsweb.cgi?r=remixbot;a=summary

你的重写应该是这样的:

RewriteRule ^\/(.+?)\/(.+?)\/?   /darcsweb/darcsweb.cgi?r=$1;a=$2 [QSA]

然而,这只是事情的一半。当这样的请求发布时,它会告诉 Apache 在哪里查看,但它不会告诉您的应用程序创建这些漂亮的 URL。除非您想破解 CGI(或者它有一个选项),否则您可能无能为力。

除了......也许重定向会起作用:

RewriteRule ^\/(.+?)\/(.+?)\/?   /darcsweb/darcsweb.cgi?r=$1;a=$2 [QSA,L]
RewriteRule ^\/darcsweb\/darcsweb.cgi?r=(.+?);a=(.+?) /$1/$2/ [QSA,R]

每次单击应用程序中的链接时,这都会导致重定向到干净的 URL...

PS:您可能要考虑使用http://blitiri.com.ar/p/darcsweb/而不是简单的 darcs CGI。

于 2011-02-20T22:07:23.680 回答