ColdFusion - Web Server - Directory Serving - IIS - iis

Not sure if this is controlled in ColdFusion Application.cfm in root directory or through the IIS webserver.
But I am trying to setup multiple subsites off of 1 Root Website using the same ColdFusion code, then setting a distinct data source by sniffing the URL ie: www.root.com/bob and using cgi.http_host.
So I can use the same code and different URL such as:
www.root.com
www.root1.com
www.root2.com
But I need to setup a separate site each time in the webserver (that is fine and understood).
But I would like to run the same code on same root website but on a subdirectory.
So I'd like to run:
www.root.com/test
www.root.com/test2
www.root.com/test3
www.root.com/newsignup
And all these subdirectories can then run the same code, without having to setup multiple websites in IIS.
Is this easily done using ColdFusion? or is it all IIS mapping?

Your code is located somewhere like
E:\path\to\wwwroot
In IIS, you have a site setup with that folder as web root. That site has a primary domain
www.someDomain.com
Then you want to serve the same code under different domains:
www.anotherDomain.com
myCFsite.someExistingSite.com
myCFsite.anotherExistingSite.com
www.YetAnotherDomain.com
In IIS, you'll have to set these up as domain aliases for your site. Look for "Bindings" in IIS Manager. You can also do this by editing the website.config file that will be created in your web root.
If you need different settings to be loaded per domain, you'll have to update your application. I usually set up database tables that map a list of those domains to their settings. That way you can lookup by cgi.http_host to find and cache settings.
<cfif !structKeyExists(application.settings, cgi.http_host)>
<!--- Look up settings, then cache them here. --->
<cfset application.settings[cgi.http_host] = ...>
</cfif>
Now you can reference settings per domain throughout the same code base.

Related

Setting up existing site on dev server, how do I make "/some folder/file" direct to the application folder instead of the server root?

I have been given a zip file of an existing site to make some changes. All of the paths within the site use a path structure that starts with "/". In an environment where the site is mapped to a domain name, that is fine. However, when I drop the site into a folder on my development server which i reference like:
"//[myserver]/[thissite]/[index.cfm]"
I get constant 500 errors because every include or location reference looks at:
"//myserver/file"
This is probably a really simple issue to resolve but in my 20 years of developing sites, I have never had to deal with it as I always use links relative to the file instead of to the site root.
My first inclination was to just replace the links with relative links but with more than 800, it is not only impractical, but additionally, I can't change every page in the site. I am just supposed to fix the things that are broken.
My development server is running ColdFusion 11 integrated with IIS so the files are located in the "c:\inetpub\wwwroot\siteFolder"
I have tried:
Setting application mapping in an application.cfc file:
this.mappings[ "/" ] = expandPath("/siteFolder");
this.mappings[ "/" ] = expandPath("/siteFolder/");
this.mappings[ "/" ] = getDirectoryFromPath(getCurrentTemplatePath());
this.mappings[ "/" ] = getDirectoryFromPath(getCurrentTemplatePath()) & "/";
Tried setting up a new site in IIS:
Creating another website in IIS and binding it to siteFolder.myserver and myserver.siteFolder both of which resulted in DNS errors
I have also converted the folder to an application in IIS and still no difference.
I am thinking there might be a way to do it through url rewriting, but before spending more time on something that may not work, I thought I was ask for a little help to see if I was on the right track.
It sounds like your current process is to drop applications into subfolders of a single CF website on your IIS server. This will generally work as the presence of an Application.cfc in the subfolder will designate it as a new application with its own scopes, etc. As you've discovered however, it will mess with any absolute paths you may have in the templates.
Your best bet is to set this up as a new site in IIS. You need to set a binding up for it (I tend to use sitename.local) and you'll need to add that to your hosts file with the following format:
127.0.0.1 yoursite.local
Once this is done, you'll want to let IIS know that this is intended to be a ColdFusion application. ACF comes with the Web Server Configuration tool which should be in your start menu. (If not, you can find it in \runtime\bin\wsconfig.exe).
This will let you select which IIS sites are expected to use CFML and will set up the IIS connectors properly.

Creating custom domain names for api

I have a web server using cpanel and I would like to use a custom domain on one folder for an api. So if I created a folder called api in the public_html folder then the path to that folder would be www.example.co.uk/api/(some php file). How could I change it so the folder would become a custom domain of api.example.co.uk/api/(some php file).
I have looked at a few options but don't really know the best way. I have tried to add a htaccsess file to the api folder and then create a rewrite rule to rewrite the www to api.
I also then looked at creating sub domains with the path to the api folder.
I have read that creating a A record on the server could work but I'm not quite sure how to do this. I know it can be done as most apis use some custom domain like facebooks graph api. (i.e https://graph.facebook.com/youtube/)
This will depend on if you have access to make DNS records for your root domain, example.co.uk. For example right now www. is a CNAME or A record (depends on how your web server is set up), that resolves to the address of your web server. If you made an identical record but named it api. (api. IN A ip-of-webserver), then api.example.co.uk would do the same thing that www.example.co.uk does. This is kind of pointless if they go to the same web server though, the /api/ part of the route makes it clear enough that the routes are for the api. What subdomains like facebook's are doing are pointing to a completely different application, and different web servers. For example, a company may have domains like mail.company.com, portal.company.com, sso.company.com, that all resolve to the address of different web servers for the different apps they have, but in this case it sounds like you are running one web server which is fine, you can have one web server be the api as well as serve the website.

IIS HTTP Redirection despite Sitecore installation

I am trying to have my Sitecore installation (IIS7.5 + Sitecore 6.5) take a subdirectory and redirect to an external website. For example:
www.domain.com -> Sitecore installed website
www.domain.com/anotherSite -> Redirects to www.anothersite.com/index.php?q=somestuff
I'm not very familiar with IIS (more of an nginx/apache guy), but I tried setting up a virtual folder for "anotherSite" then setting up an HTTP Redirect from that virtual folder to the destination. The probelm with that is that apparently Sitecore jumps in and tries to handle it before the redirect gets a chance and throws a 404.
Is there a way to intercept that one path in IIS before Sitecore gets involved and point it to an external URL?
Have a look at your web.config (or maybe a separate include file beneath ~/App_Data/Inlcudes) and search for a setting with the key IgnoreUrlPrefixes.
You might add the name of your virtual directory there to prevent Sitecore from processing these requests:
<setting name="IgnoreUrlPrefixes" value="...|/anotherSite" />

Sharing single application across a 2 subdomains in IIS7

I have an application that is currently deployed (ex. www.example.com ). However, now we have a "secure" subdomain, which will take all of the requests that need to be encrypted (ex. secure.example.com). The site that is at www.example.com is currently mapped to C:\inetpub\example.com\wwwroot\, and I've mapped secure.example.com to C:\inetpub\example.com\wwwroot\secure.
However, since secure.example.com was setup as a new website within the IIS Manager, when the secure site is visited, it displays an error since there is no web.config associated with this website; however, this is the way I want it since I want this to be a part of the application that is in the parent directory.
I think what you really meant to do was just right click on the web site for example.com and edit the bindings. In there you can add host names to that site.
Make sure you add them for port 443 which is SSL.
Map both the IIS virtual directories/web sites to the same directory, and check that are both using the same IIS application name.
(Not tried this, but can't recall seeing anything to say it would not work.)

IIS7 startup site

I have a Windows 2008 Server with IIS7 on it and a web page running under the name, let's say myApplication. I have a domain name that points to the IP of my server, let's say myApplication.com.
In order to access my application I have to enter http://myApplication.com/myApplication.
If I write http://myApplication.com/ I arrive to the IIS7 start page. Is there a way (besides rewriting the iisstart.htm to make a JavaScript or meta-data redirect) to automatically open the myApplication when someone enters "http://myApplication.com/"?
What I would like is the following:
The user enters in the browser: "http://myApplication.com/"
He/she is taken to "http://myApplication.com/myApplication"
In the URL bar of the browser only "http://myApplication.com/" shows and everything inside the application is relative to this URL.
Generally when I configure IIS, I set the properties for the "default web site" to a folder that doesn't contain anything, then create individual entries within IIS for each web site. For example, you would create a new entry for "MyApplication.com" and set its home directory to the proper folder on the server that contains your root files (usually c:\inetpub\wwwroot\myapplication.com\ but it could be anywhere you like).
It sounds as if you have created a folder for your application, but do not have a specific entry in IIS configured to handle the requests and load files from the proper folder.
If you have a dedicated IP address for the application, be sure to specify that IP within the site settings for that site. If you're using a single IP for multiple sites, configure the IP AND hostnames/domains that will be used to access that site so IIS will know which site entries belong to which domains and where to route the requests.

Resources