Feature #2650
closedRedirect option for mod_mysql_vhost
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
Updated by victord almost 10 years ago
file upload doesn't work. how can i add the patch?
Updated by victord almost 10 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)) {
Updated by stbuehler almost 10 years ago
Looks like apparmor was blocking write access :) Uploads should be working now. I also rebased the patch to the current head.
Updated by gstrauss about 9 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.
Updated by gstrauss almost 9 years ago
- Status changed from New to Need Feedback
- Target version set to 1.4.x
Updated by gstrauss over 8 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.
Updated by gstrauss about 1 year 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.
Also available in: Atom