Welcome to WebmasterWorld Guest from 22.214.171.124
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
www.website2.comThese are NOT subdomains, they do not have webspace. All domains are registered at the same hoster.
A visitor types
www.website1.comin his browser address bar. Through
.htaccess-file, a hidden redirect should happen to
www.websiteA.com(with hidden I mean that the URL does not change).
websiteA.comthe referring url determines from which folder to get the skin and what database to use to get the content from.
/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
website1.comshould 'go' to
websiteA.com/http_docs/sites/config.php, and fetch
code_standardand build the website. All the time,
website1.comshould be visible in the address bar.
How do I do this? D I need virtual hosts or aliasses or something?
All hints are welcome!
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.
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
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
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.
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?
Root (all domains point to here)
--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.