Adding subdomains w/o setting or mod_rewrite manipulation

Adding subdomains w/o setting or mod_rewrite manipulation

Wednesday 10 October 2007 10:52:47 am - 2 replies

Modified on Wednesday 10 October 2007 10:54:31 am by Piotrek Karaś

Author Message

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

You must be logged in to post messages in this topic!

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