+#ifdef FAST_REDIRECTS
+/*********************************************************************
+ *
+ * Function : redirect_url
+ *
+ * Description : Checks for redirection URLs and returns a HTTP redirect
+ * to the destination URL.
+ *
+ * Parameters :
+ * 1 : http = http_request request, check `basename's of blocklist
+ * 2 : csp = Current client state (buffers, headers, etc...)
+ *
+ * Returns : NULL if URL was clean, HTTP redirect otherwise.
+ *
+ *********************************************************************/
+char *redirect_url(struct http_request *http, struct client_state *csp)
+{
+ char *p, *q;
+
+ p = q = csp->http->path;
+ log_error(LOG_LEVEL_REDIRECTS, "checking path: %s", p);
+
+ /* find the last URL encoded in the request */
+ while (p = strstr(p, "http://"))
+ {
+ q = p++;
+ }
+
+ /* if there was any, generate and return a HTTP redirect */
+ if (q != csp->http->path)
+ {
+ log_error(LOG_LEVEL_REDIRECTS, "redirecting to: %s", q);
+
+ p = (char *)malloc(strlen(HTTP_REDIRECT_TEMPLATE) + strlen(q));
+ sprintf(p, HTTP_REDIRECT_TEMPLATE, q);
+ return(p);
+ }
+ else
+ {
+ return(NULL);
+ }
+
+}
+#endif /* def FAST_REDIRECTS */