Detecting the URL in the Address bar
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
