Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 28058

I have a couple questions, help is appreciated

$
0
0

Sorry for the arbitrary title.  I have been trying to learn URL rewriting on my own, and it has been a difficult process to say the least.  Where sometimes rules I write work as expected, other times they do not, and I've simply been unable to determine why.  So if you can take the time to help me understand, it is GREATLY appreciated.  (I am on a Win 7 Pro x64 and IIS 7.5 machine, running ColdFusion for an application language)  I know but the bare basics of RegEx.

BACKGROUND: Due to my remote host's restriction, I only have 1 site, though I can bind as many subdomains as I would like to it.  My directory structure from the root first includes folders that map to subdomains.  For example, http://projects.aaronmartone.com would map to the /projects folder off the root.  When specified, the 'www' is removed.  I would like to be able to specify which subdomains are classified as APPLICATION SUBDOMAINS (ASD) or NON-APPLICATION SUBDOMAINS (NASD).  The difference is that any request to a NASD would be written as follows:

http://projects.aaronmartone.com/folder/file.gif would come in as a URL of folder/file.gif, but the URL Rewrite Engine would change that to projects/folder/file.gif.  NASD simply ensure that the subdomain is prepended to the URL.  An ASD is different in that it works with my application language.  In the event an ASD URL is called and the path is not determined to be a .cfm or .cfml page, it should just serve it up (so files like .gif, .txt, etc, all render properly)  But in the event a .cfm or .cfml page IS called OR if the URL is determined to NOT be a file and NOT be a directory, then it rewrites as such:

http://aaronmartone.com/this/that would come in as a URL of this/that, but the URL Rewrite Engine would rewrite it as such: www/app/templates/request.cfm?$ses=this/that.  From that point, ColdFusion takes the request and processes the query string to build a response out of it.

MY CURRENT SOLUTION: So, currently I have Rewrite Maps called "Application_Subdomains" and "Non_Application_Sudomains".  And I make conditions that look at the {HTTP_HOST} with the regex pattern: (([^.]+)\.)?(.*)

This captures the subdomain in {C:2}  On my next condition (and I'm not sure this is right), in order to check if the subdomain provided was an ASD or a NASD, I do: {Application_Subdomains:{C:2}} and match it against the regex (.*)

On a sidenote, I use (.*) for rules with ASD and (.+) for rules with NASD because if the user requested my domain without the 'www', the (.*) catches that and uses the default value for the map, 'www', but there is no 'default' for a NASD.

I think I might be using Rewrite Maps improperly.  I understand that they are to be used to replace values when matched on, but I guess I'm looking for a way to have a rule only apply when it determines if either the request was on an ASD or a NASD.  

I'm going to stop there out of respect for not writing a wall.  I hope I've explained myself well enough (if not, ask, and I will attempt to clarify)  I sincerely appreciate any help you can offer.


Viewing all articles
Browse latest Browse all 28058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>