Forum Moderators: phranque

Message Too Old, No Replies

Unique Rewrite Needs for Multiple Domains - HELP!

         

stevencday

6:11 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



Ok, we have a unique setup going on, we need some help desperately...

Here's the deal:

We have developed a custom CMS product at [domain1.com....]

For all sites that will utilize the CMS, they will live at [domain1.com...]

For example, [domain1.com...]

We currently have a rewrite that works flawlessly:

RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sites/domain2.com%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule ^(.*)$ /sites/domain2.com/$1 [QSA,L]

Regardless of the pathname or querystrings passed, it works great, and we could not be happier.

On the server side, we setup domain2.com as a pointer domain to domain1.com, and here lies our trouble.

Since we setup domain2.com as a pointer domain, we are unable to create email addresses that have domain2.com as the suffix of the address. Essentially, the server sees domain2.com AS domain1.com, so for example, if I sent an email to president@domain2.com it would go to president@domain1.com.

The problem with this setup is that many of the sites we will be setting up will want president@whatever.com as their address, but we would be limited to one. That wont work.

So instead of setting up domain2.com as a pointer domain, we need to set it up as a secondary domain... Here is the folder structure for the two options, pointer and secondary:

POINTER:
domain1.com/html/sites/domain2.com/
NO DIRECTORY FOR domain2.com SINCE IT IS A POINTER DOMAIN

SECONDARY:
domain1.com/html/sites/domain2.com/
domain2.com/html/

So instead of having my rewrite rule living in the HTML folder of domain1.com, it would have to live in the HTML folder of domain2.com.

How would I need to rewrite the above rule to first change to domain1.com, and then point to /sites/domain2.com/?

I am desperate to find the solution to this...

jdMorgan

8:07 pm on Jan 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since most of the work here is in the DNS zone file, I don't think this is as complicated as you think it is. Simply set up the DNS records so that mail.domain1 and mail.domain2 point to different mail servers, and change domain1 for domain2 in the rewrite code for use on domain2. (It looks like you may have already done step 2 here.)

If instead, you mean that the president of AcmeWidget Corp. wants his e-mail address to be "president@acmewidget.com", then nothing you can do on the server or in the zone files for domain1 and domain2 is going to provide that feature; You (or he) will have to register acmewidget.com and point it to a server -- Your server, his server; It doesn't matter, but some server...

Part of the problem is the "pointer domain" term, since it's a "loose" term with no fixed technical definition. A domain is a domain, and a domain may have only a PTR record in its DNS zone file or it may be "Aliased" in the server config file, but it's still a domain. As such, there's no such as a "pointer domain", only a domain that has been pointed or aliased (or not). I don't want to appear to be pedantic, but ascribing the domain's disposition to the domain itself may be a confusing factor in this discussion.

"Pointer domain" and "add-on domain" are two sloppy terms coined by "Control Panel" authors, and their only meanings depend on precisely how the Control Panel's code maps the domains to the server filespace using Apache config file directives. This of course varies between control panel implementations.

You can certainly reproduce this code on both servers if needed (and modified to suit). The problem here isn't in writing the code, it's in stating the requirements and goals concisely, using only URLs and filepaths as the basis. In other words, define the problem using only those terms and conditions that mod_rewrite can test.

Which to be truthful, is all just an awfully-long way of saying "I guess don't understand your question." ;)

Jim

stevencday

8:29 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



I appreciate your reply. If I have not yet conveyed this, now is the time...I am over my head a bit with this...

The InterWorx Control Panel, which is the control software on the server all this is happening on, defines a 'pointer' domain to be, in my understanding, simply an 'alias' domain without any file structure represented.

An 'add-on' domain is not an alias, but an actual entity resident on the file structure, and yet a 'child', if you will, of the domain upon which is it being added.

So, for example, I have setup an account, which includes a domain, for domain1.com. The server automatically generates a file structure for this account and domain. And it would look something like this:

domain1/domain1.com/html/

When adding a 'pointer' domain, the file structure is not effected in any way. If that domain is requested it will look to the structure above to find its documents.

An add-on domain will actually create a new folder structure under the domain1/ parent folder, so there would then be two folder structures under the same domain1/ account.

domain1/domain1.com/html
domain1/domain2.com/html

Although I will be adding numerous domains, I want to have the root of each domain to be within the structure of domain1.com. For example:

If I added (as an add-on) domain2.com, domain3.com, and domain4.com, the file structure would look like this:

domain1/domain1.com/html/
domain1/domain2.com/html/
domain1/domain3.com/html/
domain1/domain4.com/html/

I would then create subfolders within domain1.com to act as the root of each site, as follows:

domain1/domain1.com/html/sites/domain1.com/
domain1/domain1.com/html/sites/domain2.com/
domain1/domain1.com/html/sites/domain3.com/
domain1/domain1.com/html/sites/domain4.com/

Leaving the rest essentially empty, not counting the .htaccess file that would live within each:

domain1/domain2.com/html/
domain1/domain3.com/html/
domain1/domain4.com/html/

All of the email will be hosted on this server, and since the InterWorx Control Panel will only allow email boxes to be created for 'add-on' domains, I must use the 'add-on' option for adding these domains. However, I don't know what the rewrite rule would be to take this:

IN BROWSER:
[domain2.com...]

HIDDEN TO THE USER:
Accesses the .htaccess file that lives in domain1/domain2.com/html and redirects to domain1/domain1.com/sites/domain2.com/

And it of course has to work even if a use types in [domain2.com...] or even [domain2.com...]

Does that makes sense?

The prospect of DNS and mail server configuration is irrelevant because all of that functionality is fine, it is a weakness in the control panel software limiting me from being able to create mailboxes for alias domains.

jdMorgan

9:24 pm on Jan 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The basic problem is that it sounds like the control panel has no option to "just point requests for both domains to the same filespace and let us sort it out in .htaccess" This can easily be done manually in httpd.conf using a ServerAlias directive, so you might want to see if you can just bypass the limited-capability control panel and do this directly in the server config file.

If not, a better option might be to upgrade your server type to a virtual dedicated host level, so you can directly-access the server config files without having to live with the control-panel limitations and multi-user-security-inspired restrictions. You'd then have total freedom to do as you please within your virtual server instance.

Jim