Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

multiple sites with one codebase and various urls

htaccess? httpdconf?



11:55 am on Dec 10, 2009 (gmt 0)

5+ Year Member

I think this post nearly gets me there, but not quite [webmasterworld.com...] (cant reply to it, as it is too old.

Does not matter what i do, i can't seem to keep the orginal domainname in the browser address bar.

I have a website at domain


I have domains
These are NOT subdomains, they do not have webspace. All domains are registered at the same hoster.

A visitor types

in his browser address bar. Through
in my
-file, a hidden redirect should happen to
(with hidden I mean that the URL does not change).


the referring url determines from which folder to get the skin and what database to use to get the content from.

folder structure:

/w/e/b/websiteA.com/http_docs/sites/config.php <- per domain a skin-folder, a databasename, and a code-folder is chosen.
/w/e/b/websiteA.com/http_docs/sites/skins <- contains skins

/w/e/b/websiteA.com/http_docs/sites/php <- contains code folders


should 'go' to
, and fetch
, database
, and
and build the website. All the time,
should be visible in the address bar.

How do I do this? D I need virtual hosts or aliasses or something?
All hints are welcome!


2:44 pm on Dec 10, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Of course these are subdomains... <anything>.domain.tld is a subdomain, whether it is hosted in a common filespace, hosted separately, or not even hosted at all. www.example.com is a subdomain of example.com, by definition.

Your code is likely implementing an external redirect instead of an internal rewrite, or the rules are ordered incorrectly, or have missing directive flags or exclusions. But I can't comment on it further, since I don't know what it looks like.



3:34 pm on Dec 10, 2009 (gmt 0)

5+ Year Member

sorry for being unclear.

When i say these are not subdomains, i meant that website1.com and website2.com are not subdomains of websiteA.com.

What i need is:

Someone types website1.com. I want it to go to websiteA.com and read config.php.
Someone types website2.com. I want it to go to websiteA.com and read config.php

I guess this will direct the browser from website1.com to websiteA.com and read config.php

RewriteEngine on
RewriteRule (.*) [websiteA.com...] [L]

But the URL changes. I would like the url in the browser address bar to show website1.com instead of websiteA.com.

Then, based on the referring url, a designfolder is chosen (each design has a separate folder), a database is chosen (each website that refers to websiteA.com has it's own database), and a codefolder (there is only one folder with php code) is chosen. This, i can do programatically.

Hope this clarifies


5:03 pm on Dec 10, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You cannot 'trust' the HTTP Referer header for this kind of function. It is an optional header, and will not be present in many requests, either because the user (or his "Internet Security" software) has disabled it, or because the client request has passed through one or more caching proxies in the network -- as are all requests from AOL and EarthLink, for example.

Malicious user-agents can easily spoof the Referer headers as well.

Further, the HTTP Referer header does not change as a result of HTTP redirection; The referrer will not show that the request has been redirected from website1.com to websiteA.

Any attempt to use HTTP Referer for 'critical' functions will fail at an unacceptable rate.

However, if you can work without the Referer header, then the other part of your problem can be addressed.

If website1 and website2 are hosted in the same filespace as websiteA (that is, their files reside in the same directory as this .htaccess code, or in a subdirectory of this directory), then you can use an internal rewrite instead of an external redirect.

If these websites are hosted on a different server, or in a different 'account' or filespace on the same server as websiteA, then the only way to 'get' those files without changing the address bar is to set up a reverse proxy. Doing this properly will require server admin access.

An alternative is to emulate a reverse proxy by passing all requests for website1 and website2 to a script, which can then open an out-going connection from your server, go fetch the content from those other servers, and then pipe it back to the requesting client. All requests for website1 and website2 will then pass through the websiteA server (and will be logged). In addition, website1 and website2 will see all requests as coming from websiteA's server, and the original requesting client's IP address, user-agent string, etc. will not be logged on those servers unless you code your script to pass the X-Forwarded-For headers (and others). Further, the website1 and website2 server's will need to be set up for custom logging in order to log those X-Forwarded headers instead of the usual ones.

Understand that the address bar is controlled by the client, and not by your server. The user "owns" that address bar. So if you want to manipulate the address bar, it is not easy. And this is intentional; A user has the right to know what domain they are actually visiting.



7:51 am on Dec 11, 2009 (gmt 0)

5+ Year Member

Thanks Jim

Your response is answering some questions, as well as raising some. As you may have noticed, this is not my field of expertise. I am curious about how a setup like this can work. I always thought that what you describe as reverse proxy is the only way to do that, and that sounds complicated. Besides, i am not sure how the server admin feels about that.

In my case, all websites will be hosted on the same server, in the same folder or a subfolder of the .htaccess file. I have never realised that it is be possible to have a domain point to ANY folder, including a subfolder of another domain. (But is this considered good usage?)

As far as i can see now, a file structure like this is possible:

websiteA.com (domain websitea.com points here)
--website1 (domain website2.com points to here)
--website2 (domain website1.com points to here)

I can refrain from using the HTTP-REFERER thingy, and just use a PHP-variable I set myself.
And my .htaccess can use internal rewrites.

Would you please share your thoughts about the folder structure i propose? Are there reasons to do it in another way?

Thanks again!


9:37 am on Dec 11, 2009 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

I never put a site directly in the 'root'.

I put them all each in their own sub-folder.


3:31 pm on Dec 11, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

If you're stuck with implementing this using only .htaccess, then I'd suggest:

Root (all domains point to here)
--sites subdirectory
--websiteA (domain websiteA.com rewritten to here)
--website1 (domain website1.com rewritten to here)
--website2 (domain website2.com rewritten to here)

This is really something that you should discuss at length with your server admin and seek his/here active participation and advice.

I think you'd be better off setting up each domain as a separate virtual server, and using mod_alias and symbolic links as required to 'share' resources such as scripts, databases, and templates, etc. This approach offers much better cross-site security than any .htaccess-based configuration, and is also much more efficient with regard to server performance.



4:11 pm on Dec 11, 2009 (gmt 0)

5+ Year Member

Thanks again, Jim. And you too, g1smd.

I will find another way together with my server administrator, possible containing aliasses etc. Your reluctance to like my solution is good enough reason for me to reject it.



Featured Threads

Hot Threads This Week

Hot Threads This Month