|Summary:||intelligently handling dynamic subdomains|
|Product:||Apache httpd-2||Reporter:||Mark Terrill <apache>|
|Component:||mod_vhost_alias||Assignee:||Apache HTTPD Bugs Mailing List <bugs>|
|Attachments:||Patch for mod_vhost_alias - from trunk|
Description Mark Terrill 2006-09-08 06:52:33 UTC
The current mod_vhost_alias does not intelligently handle 'www.'. A simple example: Request: www.example.com Config: VirtualDocumentRoot /webhome/%1.1/%0 Result: /webhome/w/www.example.com Request: example.com Config: VirtualDocumentRoot /webhome/%1.1/%0 Result: /webhome/e/example.com A messy example, involving *wildcard* dns subdomains. Request: testing.example.com Config: VirtualDocumentRoot /webhome/%1.1/%0 Result: /webhome/t/testing.example.com The common solution has been to create symlinks. Eg, between e/example.com and w/www.example.com. This is a crude solution due to requiring additional symlink lookups and manual or scripted maintenance of such symlinks - which we'd all agree is messy. Attached is a patch that allows you to use a flag called 'VirtualStripWWW' to allow mod_vhost_alias to strip any occurences of 'www.'. The default is 'on' - probably a topic of discussion. The result is you do not need to have symlinks to maintain subdomains. The patch also allows for the scenario where you have configured dynamic subdomains for a given domain and are required to show content from a directory correlating to the subdomain. Simply use a seperate virtualhost for the domain, and whatever servername you use it will not be stripped, which is very useful when you may want to keep the 'www' (eg if you have public/www, public/othersubdomain, public/yetanothersubdomain). Hopefully people find it useful. Regards, Mark
Comment 1 Mark Terrill 2006-09-08 06:53:59 UTC
Created attachment 18839 [details] Patch for mod_vhost_alias - from trunk The diff was done on a svn checkout of trunk...
Comment 2 Mark Terrill 2006-09-08 06:55:02 UTC
(In reply to comment #0) It also allows for servername coming from mod_proxy.
Comment 3 Joshua Slive 2007-09-25 11:14:19 UTC
*** Bug 29260 has been marked as a duplicate of this bug. ***
Comment 4 Dean Trower 2012-11-15 11:34:20 UTC
Could some additional syntax be implemented for this command? In addition to simply *copying* part of the server name or IP into the document root, it would be useful if you could INSTEAD choose to select between several predefined document roots based on tests applied to the server name. i.e. something like: %1=subdomain1: /webhome/firstsubdomain %1=subdomain2: /otherplace/secondsubdomain default: /webhome/www So the urls "subdomain1.example.com" and "subdomain2.example.com" would map to /webhome/firstsubdomain and /otherplace/secondsubdomain respectively, whilst anything else (e.g. example.com, www.example.com, xyz.example.com) would map to /webhome/www. This would give you the flexibility to give specific subdomains separate document roots in the filesystem, without locking the filesystem directory structure to the domain name. It also ensures that only known, prespecified directories get used as the document root (which might help avoid some security problems if the server's directory structure is set up carelessly).
Comment 5 Dean Trower 2012-11-15 11:40:51 UTC
Of course you could combine this with the existing approach: . . . default: /webhome/www/%1.1/%0
Comment 6 William A. Rowe Jr. 2018-11-07 21:09:08 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd. As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd. If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question. If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with. Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.