This also uses up your servers bandwidth rather than theirs. This article explores how I use a URL access file, either .htaccess of http.ini depending on your platform, to stop other domains from linking directly to your hosted resources.
In a recent project we are restructuring a site to be more intuitively architected. But what impact will moving the directories or pages have on all that hard earned Search Engine Ranking Optimisation work?
This article deals with how to safely redirect users from an old page or folder to the new URL, and keep Search Engine's informed of your changes without leading them to dead content (Dead content is bad and will adversely affect your Site rankings).
One of the more common tasks in ColdFusion development is passing variables through the URL string. We are all familiar with the idea that the question mark (?) denotes the url query string start, and that name value pairs are separated with the ampersand (&).
I usually avoid using this in display templates, as it isn't great exposing your internal site workings to customers, and with Fusebox it is very easy to pass the URL variables to an "act_" template and remain hidden.
What happens when you want to use dynamic url variables with a URL re writing application like Isapi re write? I've been using Isapi re write in some FuseBox framework application, and it is relatively easy to set up a rewrite rule, as shown below.
RewriteRule home(/) index.cfm?fuseaction=circuitname.circuitfunction
Where the url /home/ would actually serve up the content specified in the fuse specified. But this is hard coded. What about dynamic variables?
We can create a regular expression to handle the translation of the variables.
RewriteRule destination/(.*)/(.*)/ index.cfm?go=circuitname.circuitfunction&$1=$2
We use a similar URL, but append the dollar ($) 1 = dollar ($) 2 string. In the re write rule we specify that appended variables are transposed into the string using the slash (/) as a separator.
So as an example we could pass a product id of 24 into the rule like this:
RewriteRule buy/(.*)/(.*)/ index.cfm?go=cart.buy&$1=$2
It would be rewritten to the more familiar url string. A handy way of continuing to mask the url.
I was discussing some ideas for an application framework this morning with the team, and one of the issues we hit upon was having a common directory for templates, but serving them up as if they were from a different directory.
The idea is to have one instance of a reusable skinnable template, that appears to live on several sites.
IE all the content lives in "webroot/content/templateName.cfm", but is actually served up by many sites, IE "127.0.0.1/site1/template1.cfm", "127.0.0.1/site2/template1.cfm" ... etc
In this way they can be re skinned or adapted as needed, and they aren't database driven. The main stumbling block for the discussion was the need to actually create blank versions of each of the named templates, in each of the sites, as ColdFusion server would error on the request.
I spent twenty minutes trying to work it so that my Application.cfc's onRequest or onRequestStart method would intercept the request before it was actually made, but that just wasn't working. My other idea was to use the onMissingTemplate method, but the server is only running ColdFusion 7, so that was a no go (I figured I could catch the missing template request and just re path it, although I'd have to assess if that was really inefficient due to almost every page request logging as failed).
My eventual solution was Isapi rewrite. I am re writing all the requests to the same template, and just passing in the template variable. In that way I can request pages that don't actually exist, but they appear in the url.
Create an index.cfm template like this:
<li><a href="page1">Page 1</a></li>
<li><a href="page2">Page 2</a></li>
<li><a href="page3">Page 3</a></li>
<li><a href="page4">Page 4</a></li>
<!--- write a handler to go get the url var passed in --->
For this example I am using the free version of Helicon's Isapi rewrite, you can get it here: Link to Helicons Isapi re write
In the example below I have altered the first page link to look like it is actually a .cfm template request, just in case you want the url string to have a .fileextension look to it.
# Version 184.108.40.206
#no physical page testing
RewriteRule page1.cfm(/)? isapitest/index.cfm?p=page1
RewriteRule page2(/)? /index.cfm?p=page2
RewriteRule page3(/)? /index.cfm?p=page3
RewriteRule page4(/)? /index.cfm?p=page4
# Helicon ISAPI_Rewrite configuration file
So when you fire it up and test it you just see /page1, /page2 etc, and the pages don't actually exist.
I'm not experienced enough with Isapi rewrite to know if there is a downside to this, but bookmarking in a browser still works correctly, so I can't see an issues at present.