Adding subdomains w/o setting or mod_rewrite manipulation

Author Message

Piotrek Karaś

Wednesday 10 October 2007 10:52:47 am

Let's say we've got a one-class-based flat-structured catalog of items of whatever sort. The standard addressing for the full view of each node can be:
System:
<b>/content/view/full/[ITEM_ID]</b>
or
Virtual:
<b>/[WHATEVER]/[THE]/[ITEM_OBJECT_NAME]</b>

Would it be possible to add a unique subdomain for each item so that the full view is also accessible with that subdomain? But, of course, without having to configure anything (settings, .htaccess, mod_rewrite etc.) each time we add/edit/remove an item?

For example:
<b>subdomain1.domain.com</b> -> <b>/content/view/full/123</b>
<b>subdomain2.domain.com</b> -> <b>/content/view/full/5423</b>

Is it even possible with eZ Publish? Any ideas?
Thanks

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Betsy Gamrat

Thursday 11 October 2007 4:46:44 pm

Cool question! :)

I'd create a .conf file to include into the Apache .conf settings. This would probably have to be generated by an eZ extension, executed by runcronjobs.php.

The .conf file would have a VirtualHost directive like so:

<VirtualHost 127.0.0.1>
ServerName example.com
ServerAlias www.example.com
ServerAlias subdomain1.example.com
ServerAlias subdomain2.example.com
DocumentRoot /home/example/public_html/ez

... Standard rewrite rules ...

</VirtualHost>

I'd also append the siteaccesses into site.ini.append.php, like so:

MatchOrder=host
HostMatchMapItems[]=example.com;site_user
HostMatchMapItems[]=subdomain1.example.com;site_user
HostMatchMapItems[]=subdomain2.example.com;site_user
HostMatchMapItems[]=admin.example.com;site_admin

Resources:

http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

Check "Extended Redirection" - you may be able to write the Perl code to perform the redirection with a script as part of your extension.

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Check "RewriteMap" - you may be able to effectively create an array.

Good luck!

Piotrek Karaś

Wednesday 17 October 2007 9:27:57 am

Thanks for your reply, Betsy. I will definitely give it a deeper look.

Meanwhile, I think I have come up with a solution that maybe will not stand a universal one, but may fit into our hosting environment configuration. Just in theory for now:

1) I configure my HTTP server so that a given domain and any user-dynamically-created subdomains of any level direct the root of the installation. That will probably require a wildcard of some kind. Lets say, I've got a <b>domain.com</b> domain and I setup a <b>*.domain.com</b> rule, meaning * can be anything.

2) I create a mod_rewrite rule which reads the requested SERVER_NAME and extracts (and validates/secures) whatever the subdomain part name is (if there is anything in place of <b>*</b>), and redirects to something like this:
<i>/domain.com/index.php/default_siteaccess/content/view/subdomain/(name)/*</i>
where * is whatever the subdomain was.

For example:
<i>letstry.domain.com</i> <b>is rewritten to</b> <i>/domain.com/index.php/mysite/content/view/subdomain/(name)/letstry</i>

3) Now it's easy to create a template override for a given class and for the mode "subdomain" of the view view of content module. I can easily grab the value of "name" parameter, and it all gets down to is a fetch in the template (a "subdomain" attribute in the class would be useful).

---

I still have to make this empirical, but I have good feelings about it ;)
Will get back to this issue ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 00:59:15
Script start
Timing: Jan 19 2025 00:59:15
Module start 'layout'
Timing: Jan 19 2025 00:59:15
Module start 'content'
Timing: Jan 19 2025 00:59:16
Module end 'content'
Timing: Jan 19 2025 00:59:16
Script end

Main resources:

Total runtime1.1098 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.4141152.6563
Module start 'layout' 0.00610.0027 742.070339.5078
Module start 'content' 0.00871.0997 781.5781558.2578
Module end 'content' 1.10850.0013 1,339.835916.0938
Script end 1.1098  1,355.9297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3144160.0002
Check MTime0.00130.1192160.0001
Mysql Total
Database connection0.00120.111110.0012
Mysqli_queries1.047894.4154570.0184
Looping result0.00050.0474550.0000
Template Total1.069896.420.5349
Template load0.00230.205920.0011
Template processing1.067596.185120.5337
Template load and register function0.00010.007310.0001
states
state_id_array0.00140.128910.0014
state_identifier_array0.00160.141420.0008
Override
Cache load0.00200.1807550.0000
Sytem overhead
Fetch class attribute can translate value0.00080.073920.0004
Fetch class attribute name0.00090.083350.0002
XML
Image XML parsing0.00080.073720.0004
class_abstraction
Instantiating content class attribute0.00000.001360.0000
General
dbfile0.00220.1956230.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs