Copy link to clipboard
Copied
Hi all,
I've been trying to get this to work for over a week and it's driving me nuts.
I need to know what the actual, full address that was TYPED or passed through a link into the address bar is.
My problem here is that I'm trying to detect it on an index.cfm page - the home page of the site.
So, if someone were to type www.whatever.com/index.cfm - I need to know that they typed all of that.
If someone just typed www.whatever.com - without the index.cfm - I need to know.
The problem is, when someone types in www.whatever.com, the ColdFusion server automatically serves up index.cfm, because it's the default page.
Using cgi variables I can get the domain name - but even if the visitor didn't actually type the /index.cfm into the address bar (and even though /index.cfm isn't displayed in the address bar) the cgi variables still bring it back - because it's the default page.
You may ask 'why' I need this.
Google is punishing my site for duplicate content because www.whatever.com is the same page as www.whatever.com/index.cfm
I know. Stupid, but they're doing it.
I cant do a 301 redirect of index.cfm to the domain name, because it just loops and never completes.
What I want to do is detect if /index.cfm is actually part of the URL used in the address bar. If it is, I'll do an internal 301 redirect to the domain name without the /index.cfm as part of the address. That way, if someone comes along with /index.cfm in the address bar (or if a link has index.cfm in it), they get redirected to the domain name - land on the same page without the /index.cfm in the address bar, and since /index.cfm isn't in the address bar - the page doesn't need to be redirected.
That stops the looping effect caused by a 'real' 301 redirect.
I'm on an IIS platform so I cant use an .htaccess file to do this - and I'm not even sure it would actually work anyway. Redirecting a page back onto itself doesn't work too well ![]()
I've tried using the coldfusion cgi variables, all sorts of different javascript code, and even begged the computer to just lie down and do as I ask - but I can't find a way to NOT bring back /index.cfm even if it wasn't part of the actual URL used to reach the home page of the site.
Any ideas would probably keep me from having a stroke.
Thanks!
WHeis
Copy link to clipboard
Copied
Try this:
<cfset stHttpRequestData = getHttpRequestData()>
<cfoutput>#stHttpRequestData.headers["X-REWRITE-URL"]#</cfoutput>
That said, IIS does do rewrites - if not via .htaccess - so you should solve your issue that way, rather than trying to do it with CF.
From IIS7, rewriting is a built-in module. For earlier versions one can get Helicon's ISAPI rewrite, which does indeed use .htaccess.
--
Adam
Copy link to clipboard
Copied
Hi Adam,
Thanks for the idea, but unfortunately it didn't work.
I just got errors about the X-REWRITE-URL part, and also found that a dump of the data from the request didn't include anything about the actual file name being requested.
I did manage to 'fix' the issue (I hope) by setting the default page for the directory to index.htm
Then I created a blank index.htm file, dropped it in the root directory, and then used IIS to redirect it to index.cfm
Now, no matter how someone wants to reach the site, it will show up with the domain name followed by /index.cfm
Would have been 'cleaner' to just have it show the domain name only - but the issue is that Google is seeing the domain name by itself, and the domain name followed by index.cfm as two separate files and calling it duplicate content.
Now Google cant do that because of the redirect.. it'll only hit the index.cfm file from here on out.
Best I could do for now.
I will look into the Helicon system, but if this accomplishes what our SEO guy says needs to be done - we'll save the fun of learning another thing for another day ![]()
THanks!
WH
Copy link to clipboard
Copied
The issue _could_ perhaps be resolved by modifying CF code; but it seems to me that the issue is more SEO than CF. I'm no SEO expert, but I believe that there are a line or two of code that is not CF that will prevent Google from seeing www.whatever.com and www.whatever.com/index.cfm as the same page. I'm not recalling it, at the moment, but I did Google "SEO tips and tricks" a few months ago, and saw an article that explained best practices for SEO and this was one of the ideas.
Best of luck,
^_^
Find more inspiration, events, and resources on the new Adobe Community
Explore Now