4 USE_FEATURE_HTTPD_BASIC_AUTH(" [-r realm]") \
5 USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
9 + " [-R <path> [-H <host>]]"
10 #define httpd_full_usage "\n\n" \
11 "Listen for incoming HTTP requests\n" \
14 "\n -h HOME Home directory (default .)" \
15 "\n -e STRING HTML encode STRING" \
16 "\n -d STRING URL decode STRING" \
17 + "\n -R PATH Redirect target path" \
18 + "\n -H HOST Redirect target host" \
20 #define hwclock_trivial_usage \
22 --- a/networking/httpd.c
23 +++ b/networking/httpd.c
26 const char *found_mime_type;
27 const char *found_moved_temporarily;
28 + const char *redirect_path;
29 + const char *redirect_host;
30 Htaccess_IP *ip_a_d; /* config allow/deny lines */
32 USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
34 #define index_page (G.index_page )
35 #define found_mime_type (G.found_mime_type )
36 #define found_moved_temporarily (G.found_moved_temporarily)
37 +#define redirect_path (G.redirect_path )
38 +#define redirect_host (G.redirect_host )
39 #define last_mod (G.last_mod )
40 #define ip_a_d (G.ip_a_d )
41 #define g_realm (G.g_realm )
45 if (responseNum == HTTP_MOVED_TEMPORARILY) {
46 - len += sprintf(iobuf + len, "Location: %s/%s%s\r\n",
47 + len += sprintf(iobuf + len, "Location: %s%s%s%s%s%s\r\n",
48 + (redirect_host ? "http://" : ""),
49 + (redirect_host ? redirect_host : ""),
50 found_moved_temporarily,
51 + (redirect_host ? "" : "/"),
53 (g_query ? g_query : ""));
55 @@ -1912,8 +1919,12 @@
57 *++urlp = '\0'; /* terminate after last character */
59 + /* redirect active */
60 + if (redirect_path && (strncmp(urlcopy, redirect_path, strlen(redirect_path)) != 0))
61 + found_moved_temporarily = redirect_path;
63 /* If URL is a directory, add '/' */
64 - if (urlp[-1] != '/') {
65 + if (!redirect_path && (urlp[-1] != '/')) {
66 if (is_directory(urlcopy + 1, 1, &sb)) {
67 found_moved_temporarily = urlcopy;
73 - c_opt_config_file = 0,
74 + R_opt_redirect_path = 0,
75 + H_opt_redirect_host,
79 USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
80 @@ -2312,12 +2325,13 @@
81 /* We do not "absolutize" path given by -h (home) opt.
82 * If user gives relative path in -h,
83 * $SCRIPT_FILENAME will not be set. */
84 - opt = getopt32(argv, "c:d:h:"
85 + opt = getopt32(argv, "R:H:c:d:h:"
86 USE_FEATURE_HTTPD_ENCODE_URL_STR("e:")
87 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
88 USE_FEATURE_HTTPD_AUTH_MD5("m:")
89 USE_FEATURE_HTTPD_SETUID("u:")
91 + &redirect_path, &redirect_host,
92 &configFile, &url_for_decode, &home_httpd
93 USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
94 USE_FEATURE_HTTPD_BASIC_AUTH(, &g_realm)