Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess重写规则多次运行脚本_Apache_.htaccess - Fatal编程技术网

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

Apache .htaccess重写规则多次运行脚本,apache,.htaccess,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

这个重写规则似乎在一个请求中运行我的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
如何制定一个重写规则,只为evry请求启动cgi脚本一次

cgi脚本
注释掉DirectoryIndex并澄清您是如何验证对/joppi.bot的web请求被调用了3次的?您知道浏览器是如何从服务器请求资源的吗?特别是,你知道网页、网页上的图像、css和javascript文件是如何加载的吗?是的,我知道。。但是没有加载任何资源。。它是纯文本的。用当前正在运行的脚本更新了答案,不是真的。。但它让我了解了我是如何知道它运行多个时间的。我对DirectoryIndex@anubhava进行了注释,首先它工作了,在一段时间后,它一次更新回3个调用。。。我觉得有些东西坏了。@Erik:我对fcgi不是很熟悉,但afaik mod_rewrite只会重写东西。重写完成后,它将重写的字符串交给Apache,并告诉它:使用它做一些有用的事情!例如,/blah的请求只会重写一次到joppli.bot。我可以想象,如果您没有favicon,它也可能会将其改写为joppli.bot。如果您的浏览器想要查找更多文件,也可以这样做。测试重写规则^blah$joppli.bot并访问yoursite.com/blah。这也有同样的问题吗?
#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"));
}