Project

General

Profile

Actions

Feature #2650

closed

Redirect option for mod_mysql_vhost

Added by victord almost 9 years ago. Updated 3 months ago.

Status:
Obsolete
Priority:
Normal
Category:
mod_mysql_vhost
Target version:
-
ASK QUESTIONS IN Forums:
No

Description

This patch adds the option to specify a redirect instead of a docroot for a domain.

- if the specified docroot starts with a '/', it's a directory
- else it's a URL and we do a redirect appending the incoming query params

TODO: enable the feature using a config flag


Files

mysql-redirect-option.patch (1.19 KB) mysql-redirect-option.patch stbuehler, 2015-06-16 21:56
Actions #1

Updated by darix almost 9 years ago

ENOPATCH

Actions #2

Updated by victord almost 9 years ago

file upload doesn't work. how can i add the patch?

Actions #3

Updated by victord almost 9 years ago

Index: mod_mysql_vhost.c
===================================================================
--- mod_mysql_vhost.c    (revision 2826)
+++ mod_mysql_vhost.c    (working copy)
@@ -383,6 +383,25 @@

     /* sanity check that really is a directory */
     buffer_copy_string(p->tmp_buf, row[0]);
+
+    /* if it does not start with '/', we redirect */
+    if (p->tmp_buf->used && p->tmp_buf->ptr[0] != '/') {
+        if (result) mysql_free_result(result);
+#if MYSQL_VERSION_ID >= 40100
+        while (mysql_next_result(p->conf.mysql) == 0);
+#endif
+        buffer_append_string_buffer(p->tmp_buf, con->uri.path);
+        if (con->uri.query->used) {
+            buffer_append_string(p->tmp_buf, "?");
+            buffer_append_string_buffer(p->tmp_buf, con->uri.query);
+        }
+        response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->tmp_buf));
+        con->http_status = 301;
+        con->mode = DIRECT;
+        con->file_finished = 1;
+        return HANDLER_FINISHED;
+    }
+
     BUFFER_APPEND_SLASH(p->tmp_buf);

     if (HANDLER_ERROR == stat_cache_get_entry(srv, con, p->tmp_buf, &sce)) {

Actions #4

Updated by stbuehler almost 9 years ago

Looks like apparmor was blocking write access :) Uploads should be working now. I also rebased the patch to the current head.

Actions #5

Updated by gstrauss almost 8 years ago

What is the intended use of this feature? I am guessing a large hosting where a site is now "Gone" and you want to redirect to give that message. I guess that because the patch hard-codes 301 response.

While less efficient, the above can be done by setting docroot to a specific physical path which contains no files, and then using a dynamic handler with mod_indexfile.

Back to the patch at hand, maybe if the returned docroot does not begin with '/', the returned value could begin with a status code, such as 301, 302, or 410. If 301 or 302, then it should be followed with a path to be used as prefix for Location response header.

Actions #6

Updated by gstrauss almost 8 years ago

  • Status changed from New to Need Feedback
  • Target version set to 1.4.x
Actions #7

Updated by gstrauss over 7 years ago

  • Status changed from Need Feedback to Missing Feedback

If still interested in this feature, please re-open issue and answer questions above. Thanks.

Actions #8

Updated by gstrauss about 7 years ago

  • Target version deleted (1.4.x)
Actions #9

Updated by gstrauss 3 months ago

  • Status changed from Missing Feedback to Obsolete
  • ASK QUESTIONS IN Forums set to No

mod_mysql_vhost was replaced with mod_vhostdb_mysql in lighttpd 1.4.46.

Actions

Also available in: Atom