create a whitelabel website and point domains to it - iis-7

I'm after a little advice. I have a few websites which all essentially serve the same content. I have say websiteA, websiteB and websiteC. Each one points to one database to serve the content (think of it as a dating website). Each website has a folder in wwwroot and is mapped to the relevant domain name.
What I'd like to be able to do is have one website, say website A and simply point each of the domain names to that one site. However, how would I then make each site look different? Do I need something within websiteA which say if the referring URL is websiteB.com - serve this style sheet... if the website referring is WebsiteC.com then serve this CSS.
I suppose it's like creating a whitelabel service? I just don't know where I'd start!
Many thanks.
(PS: We have a windows dedicated server with IIS7)

The easiest option would be to react to the HTTP_HOST header, which will tell you which website the request if for, even if they're all mapped to the same folder.

Related

How do I serve a firebase site using the domain from another firebase site?

I have a firebase site with a domain of gs-domain1.web.app.
I have a second firebase site with a domain of gs-domain1.web.app.
Now, I want all traffic to go through the gs-domain1.web.app. However, when the path matches a specific route, like, /users/:id/pages, I want the site on gs-domain2.web.app to take over without switching the domain, but maintaining the path.
I believe a redirect will not work because it physically switches the domain.
I believe a rewrite will not work because I can't recreate the path on the destination.
Both the application on domain1 and domain2 are single-page applications (react and vue respectfully).
In firebase, you could host more than one site in one project and that would solve your problem.
Host/Deploy the react code to firebase and link the site with the URL of gs-domain2.web.app
and
do another hosting in the same project as the react but vue on gs-domain2.web.app
After you have successfully linked the domain and hosted the sites... Link the URL together with or anyone you like.
PROS: Your sites would load separately and would be faster.
Also,
It would be great if you put all the code under one domain
Then you can use different paths for the 2 sites so they would be easily identifiable.
so you have : gs-domain1.web.app/path1 and gs-domain1.web.app/path2
You will find the add another site function at the bottom of the hosting section below 1
I am not sure exactly what you mean by "take over without switching the domain, but maintaining the path". If you mean that you want the user to now see the page on gs-domain1.web.app when at this specific path, but still have gs-domain1.web.app as the domain in the url in their browser, I can only really think of two good ways to do this.
You use an iFrame to display the page from gs-domain2.web.app as the entire contents of the page on gs-domain1.web.app at the specific path. This can potentially introduce weirdness if the second page is complex.
You get rid of the second domain and instead move that codebase over to the first domain and write some middleware that serves from the first codebase whenever the user is requesting a path that should come from gs-domain1.web.app currently and serves from the second codebase whenever a user requests a path that should currently be coming from gs-domain2.web.app. I feel that this would be the more 'correct' approach if this is the desired behavior you want.
Alternatively, if you do not care what domain the user is seeing, I would suggest, as you mentioned, merely setting up some clever redirects to bounce users between the two based on which path they are requesting.
I hope this was helpful and goodluck!

Storing site specific configuration data

I have been given a job to re-develop a news portal. The website already has couple of thousands of unique visits a day. I am going to develop it using ASP.NET webforms. I am currently in the planning phase and I am thinking to offer the main admin a page where he can change site specific configuration information. Some of these are;
Web site title "<title>"
site URL
footer text
default image directory
whether to accept comments without authorisation or not
I listed above some settings so that you can understand my scenario better.
What I can't decide is, where to store all this information. Do I store them in a DB (costly?), a custom XML file? or a .config file. e.g. ConfigurationManager.AppSettings
Any pros or cons would make my day!
Thank you!
My opinion is to store them on web.config on WebConfigurationManager.OpenWebConfiguration().GetSection() because this variables are critical and change only ones - in the initialize of the site.
For example the default image directory is stay the same for the rest of the site life, the same and the site URL the same and the other.
Also when you change this settings probably you need also a restart of the web application because for sure you need to re-read them on some static variables.
And because this variables are stay as is, and need them for start the web (then you read the database and the rest) you need to have it in first hand, from the web.config.

Plone, behaviour of URLs

The situation is the following: I created a site with Plone, developed, used, but behind a test URL. Now it has to be published, but the test URL is not appropriate and I don't want to move the site. I think, if I use a redirect, it won't be appear in the URL-bar, only in the case of site start page. Am I wrong? (The test URL should not be used, because it will be a "semi-official" site.) What do you suggest to do?
As far as I can see Plone uses absolute URLs everywhere. I can add relative URLs, but if I create a new page, a new event, etc., then they have absolute URLs on other automatically generated inner pages. Is there any way to convert these URLs to relative paths? Is there any setting possibilty where only a checkbox changes this default setting?
Plone does not store your URLs in the database. It uses the inbound host header (and any virtual hosting configuration set up with rewrite rules in Apache or Nginx) to calculate the correct absolute URL when rendering the page.
In other words - as soon as you actually point the relevant domain name to the server with your Plone instance, it'll just work.
P.S.
You should put a bit more effort into asking your question. This is just a copy and paste of a half-finished email chain where you tried to get the answer from me in private. It's not very easy to understand what you're asking.
I think what you are looking for is url rewriting to handle virtual hosting. ie to get your site to appear as if it's the root url of a domain.
This is normally done via the webserver that normally sits in front of plone. For apache, here is a howto
http://plone.org/documentation/kb/plone-apache/virtualhost
for other servers
http://plone.org/documentation/manual/plone-community-developer-documentation/hosting
You can also achieve this directly in zope (via ZMI) using something called the Virtual Host
Monster. see http://docs.zope.org/zope2/zope2book/VirtualHosting.html
PS. I don't think your question is badly worded. Plone does serve pages with a "base" tag and what appears to be absolute urls. They aren't baked into the database but it's also not obvious that the solution to getting the url you want is the VHM url syntax and a proxying frontend webserver. There is a reason why it doesn't use relative urls... which I can't remember it was so long ago.

resources on secured web site

We have a web site in the domain, let's name: http://website.com. It is necessary to implement same look-and-feel on another web site (https://custom.website.com). As we can see, the 2nd is in the sub-domain of the 1st one, but it is secured (it uses https).
To achieve same look-and-feel same DLLs are used in both web sites. These DLLs contain functionality for menus, JavaScripts, etc). But the 2nd web-site uses images and some css files from the 1st one. For example, in order to display "Logo.png" instead of usual "~/Images/Logo.png" the following path to file is rendered into HTML: "http://website.com/Images/Logo.png"
All stuff was done on the local environment, and work perfect (http://localhost/ referred to http://website.com).
BUT, when web-site was deployed to 'real' (development) environment we got surprise: IE notifies:
webpage contains content that will not be delivered using a secure HTTPS connection
I see option to resolve an issue: we could include images into secured web site and use them locally, but in this case we will need to do redeployment if something changed on the main web site.
Question: is there any workaround, how from secured web site we could use images that are located on the non-secured.
Thanks. Any thoughts are welcome.
P.S. I am using ASP.NET 3.5, web sites are hosted under Windows 2008
You need to host your images, CSS and scripts (more generally, whatever is loaded from the webpage) on your HTTPS site too to avoid mixed-content.
Depending on the level of security and isolation you could set up a shared virtual directory for the two websites that point to the same physical location.
Example, create a directory at C:\inetpub\shared-static and create a virtual directory /static under each website pointing to C:\inetpub\shared-static. From there both websites can refer to the image like ~/static/logo.png as necessary for shared content. When the directory has a new file (or replaced file) placed in it, both websites will refer to the same file.
If you can enable support of https on the main web site, you could use https for the image urls instead of http.
Alternative as others have suggested is to sync images / or used a shared location when serving them.
I see workaround:
on the 2nd web-site implement functionality that will check (once per day or per hour) if own images are the latest and update them when necessary...
That is a some work, but with such solution web site will be easier to support.
If you see a better option, please let me know.
Thanks.

Multiple domains, same web application on IIS 6

On IIS 6, is it possible to have multiple domain names pointing to the same web application, and conditionally serve CSS from within the web application based on the domain name?
I need to host hundreds of different "skins" on the same web application, with the skin being dependent upon the domain name, and I really don't want to launch tons of web applications.
+1 to rhinof for adding multiple identities, but creating a HttpModule is a bit over kill. You can simply switch the URL of the tag in a Master Page by examining the contents of Request.Headers["HOST"]
1) add the desired domain names as website identifiers in the advanced property page of the Web Site Tab.
2) map the .css extension to the aspnet_isapi.dll
3) write an httpmodule that will re write the url for .css requests based on the domain name
4) enable your module via the web.config
If you use themes, you can change the theme, thereby changing the css, etc. in the Page.PreInit depending on the value of the domain in Request.ServerVariables["Url"] (note, there might be a better server variable to get the domain name, look it up).
If you aren't using themes, you can programatically swap out the css file by checking the same server variable.
MasterPages are going to be your friend here.
Hope that shoves you in the right direction. It is possible and common.
If you are going to have different core content on the sites then I suggest putting in a global identifier to track which site a user is on and put your data in a DB somewhere for reference against that identifier. This is by far the easiest way to extend the app if each instance is unique.
You can put this into a class and have one common pattern for figuring out where stuff should map to. I suggest that once you know the mapping to cache that and then you will be able to do what you want without the latency of a thousand apps or db calls.
You will also need to add this parameter on any general DB calls so that you only get results for the domain that is being hosted. I’ve got a bit of experience with this so just leave some comments if you want to see some specific coding examples.
You can apply this technique to any file, CSS stylesheet or object for referencing purposes.
Yes, this should be simple to do. I'd go with the approach of mapping the domain names to your app using host headers in IIS. Then, as Martin said, interrogate Request.Headers["HOST"] in your app to switch the stylesheet.

Resources