.htaccess 使用G-WAN限制图像热链接

.htaccess 使用G-WAN限制图像热链接,.htaccess,hotlinking,g-wan,.htaccess,Hotlinking,G Wan,我想为静态库提供服务,我想知道G-WAN是否可以限制对指定文件的热链接 限制图片热链接会很好,但我真正想知道的是,是否有可能不允许热链接图片,但允许名称以“_thumb”(缩略图)结尾的热链接图片 谢谢 以下是如何继续: 如果要将检查限制为*.gif或*.png文件,可以使用G-WAN“连接处理程序”或MIME“内容类型处理程序”执行此操作: http_t *http = (http_t*)get_env(argv, HTTP_HEADERS); static char my_site[]

我想为静态库提供服务,我想知道G-WAN是否可以限制对指定文件的热链接

限制图片热链接会很好,但我真正想知道的是,是否有可能不允许热链接图片,但允许名称以“_thumb”(缩略图)结尾的热链接图片


谢谢

以下是如何继续:

如果要将检查限制为*.gif或*.png文件,可以使用G-WAN
“连接处理程序”
或MIME
“内容类型处理程序”
执行此操作:

 http_t *http = (http_t*)get_env(argv, HTTP_HEADERS);

 static char my_site[] = "www.my_site.com";
 if(strcmp(my_site, http->h_referer)) // not my site
 {
    char *request  = (char*)get_env(argv, REQUEST);

    if(strstr(request, "_thumb"))
       return 0; // 0: Close the client connection
 }

 return 255; // continue normally
或者,您可以重定向到其他页面或图像,而不只是关闭连接:

    char szURI[] = "http://another-place.org";
    xbuf_t *reply = get_reply(argv);
    xbuf_xcat(reply,
              "<html><head><title>Redirect</title></head>"
              "<body>Click <a href=\"%s\">here</a>.</body></html>",
                    szURI);

    // set the HTTP reply code accordingly
    int *pHTTP_status = (int*)get_env(argv, HTTP_CODE);
    if(pHTTP_status)
       *pHTTP_status = 301; // 301:'moved permanently'

    // 2: Send a server reply based on a reply buffer/HTTP status code
    return 2;
char szURI[]=”http://another-place.org";
xbuf_t*reply=get_reply(argv);
xbuf_xcat(答复,
“重定向”
“点击。”,
szURI);
//相应地设置HTTP应答代码
int*pHTTP_status=(int*)get_env(argv,HTTP_代码);
如果(pHTTP_状态)
*pHTTP_状态=301;//301:“永久移动”
//2:基于应答缓冲区/HTTP状态代码发送服务器应答
返回2;

以下是如何继续:

如果要将检查限制为*.gif或*.png文件,可以使用G-WAN
“连接处理程序”
或MIME
“内容类型处理程序”
执行此操作:

 http_t *http = (http_t*)get_env(argv, HTTP_HEADERS);

 static char my_site[] = "www.my_site.com";
 if(strcmp(my_site, http->h_referer)) // not my site
 {
    char *request  = (char*)get_env(argv, REQUEST);

    if(strstr(request, "_thumb"))
       return 0; // 0: Close the client connection
 }

 return 255; // continue normally
或者,您可以重定向到其他页面或图像,而不只是关闭连接:

    char szURI[] = "http://another-place.org";
    xbuf_t *reply = get_reply(argv);
    xbuf_xcat(reply,
              "<html><head><title>Redirect</title></head>"
              "<body>Click <a href=\"%s\">here</a>.</body></html>",
                    szURI);

    // set the HTTP reply code accordingly
    int *pHTTP_status = (int*)get_env(argv, HTTP_CODE);
    if(pHTTP_status)
       *pHTTP_status = 301; // 301:'moved permanently'

    // 2: Send a server reply based on a reply buffer/HTTP status code
    return 2;
char szURI[]=”http://another-place.org";
xbuf_t*reply=get_reply(argv);
xbuf_xcat(答复,
“重定向”
“点击。”,
szURI);
//相应地设置HTTP应答代码
int*pHTTP_status=(int*)get_env(argv,HTTP_代码);
如果(pHTTP_状态)
*pHTTP_状态=301;//301:“永久移动”
//2:基于应答缓冲区/HTTP状态代码发送服务器应答
返回2;