我有一个FastCGI脚本,我希望每个请求redirect到它,无论哪个URL。 我目前的虚拟主机configuration如下:
<VirtualHost *:80> ServerName localhost FastCGIExternalServer /var/www/localhost/cgi-bin/ws -host 127.0.0.1:2000 Alias / /var/www/localhost/cgi-bin/ws DocumentRoot /var/www/localhost/cgi-bin/ <Directory /var/www/localhost/cgi-bin/> SetHandler fastcgi-script Options +ExecCGI Options +FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
如果我在浏览器上打开URL http://localhost ,则可以成功查看由CGI脚本呈现的页面。 但是,如果我尝试任何其他页面,我从Apache获得一个错误的404页面,这意味着该请求没有redirect到我的CGI脚本。
我在/var/www/localhost/cgi-bin/添加了下面的.htaccess文件,其中包含以下mod_rewrite规则:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}wc [NC,L]
但是现在我得到的只是一个Apache错误500页面,并且在Apache日志中有一条警告消息:
由于可能的configuration错误,请求超出了10个内部redirect的限制。 如果需要,使用“LimitInternalRecursion”来增加限制。 使用“LogLeveldebugging”来获得回溯。
我怎样才能解决这个问题,并正确地将每个请求redirect到我的FastCGI脚本?
我不明白为什么,但改变后,它工作:
从
Alias / /var/www/localhost/cgi-bin/ws
至
Alias / /var/www/localhost/cgi-bin/
此外,我清理了我的.htaccess只是为了让事情更漂亮(删除检查现有的文件和目录):
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}wc [NC,L]
如果有人了解它的工作原理,请在评论或其他地方解释。 我真诚地认为,Apache的configuration要么是一团糟,要么是我的理解能力。