.htaccess重写规则多次运行脚本

时间:2014-11-19 20:32:42

标签: apache .htaccess

这个重写规则似乎在一次请求时运行了我的cgi脚本joppli.bot 3次。

RewriteEngine On

# remove trailing slash
RewriteRule ^(.*)/$ /$1 [L,R=301]

# add trailing slash
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^.*[^/]$ /$0/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ joppli.bot [NC,L]

DirectoryIndex joppli.bot

如何为ev​​ry请求创建一次仅启动cgi脚本的重写规则?


cgi脚本

#include "fcgi_stdio.h"
#include <stdlib.h>

void main(void)
{
    int count = 0;
    while(FCGI_Accept() >= 0)
        printf("Content-type: text/html\r\n"
               "\r\n"
               "<title>FastCGI Hello!</title>"
               "<h1>FastCGI Hello!</h1>"
               "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("SERVER_NAME"));
}

0 个答案:

没有答案