• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

redirect of index.cfm without a loop

LEGEND ,
Apr 17, 2006 Apr 17, 2006

Copy link to clipboard

Copied

Hi there,

Is there any way to use CF to differentiate between a URL that contains
index.cfm and one that doesn't eg.

http://www.site.com/
http://www.site.com/index.cfm

The CGI script_name and path_info are the same. I think windows
differentiates for log files, but I need to get CF to work this for me.

Any ideas?

Thanks in advance,

Rich
TOPICS
Advanced techniques

Views

4.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2006 Apr 17, 2006

Copy link to clipboard

Copied

Try the cgi.http_referrer variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2006 Apr 18, 2006

Copy link to clipboard

Copied

The problem you are going to run into is that most web servers take a request for http://www.site.com or http://www.site.com/ and turn that into a 302 for the index document as specified in the web config, i.e.

- client requets http://www.site.com from server
- server sends a http 302 -> client = http://www.site.com/index.cfm
- client sends an new http 200 -> http://www.site.com/index.cfm

The reason you have the differentiation in your web server log is that each of the requests above is sometimes a separate line looking something like this:

1.2.3.4 - - [01/Apr/2006:01:01:01 GMT] "GET / HTTP/1.1" 302 941272
1.2.3.4 - - [01/Apr/2006:01:01:01 GMT] "GET /index.cfm HTTP/1.1" 200 941286

Now, the CGI.HTTP_REFERER variable that Dan mentioned will tell you about requests that *probably* don't have index.cfm in the request header, but it won't account for bookmarks and referers from https (b/c that variable isn't passed on requests from https -> http). If you can live with those exceptions, then Dan's suggestion is definitely the way to go.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 21, 2006 Apr 21, 2006

Copy link to clipboard

Copied

Thanks for the reply - sorry to not get back to you.

I still have the problem that the CGI.HTTP_REFERER does not allow me to
differentiate between www.site.com and www.site.com/index.cfm to allow
me to redirect the second to the first without making an infinite loop.
This is being used for SEO purposes to stop google listing these as 2
separate pages - they really do make life complicated!!

Rich

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 22, 2006 Apr 22, 2006

Copy link to clipboard

Copied

I won't ask why you are doing such a, ah, interesting exercise.

If you are doing the aforementioned redirection, set a cookie, session, or URL variable and then you can differentiate between normal redirects and your own.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 23, 2006 Apr 23, 2006

Copy link to clipboard

Copied

I have to agree with MikerRoo about the "interesting exercise" part ... But if you just need an easy way to deal with Google and this has nothing to do with tracking users, why not just do some special handling for the googlebot in Application.cfm, whatever handling that might be?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2006 May 25, 2006

Copy link to clipboard

Copied

I'm back on this same issue again and can't believe I haven't found a
solution. I can isolate google, but I still have the infinite loop
problem to solve once isolated. If there is no way to differentiate, CF
cannot tell if index.cfm is included in the URL or not. It will
therefore always try to redirect....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2006 Jul 01, 2006

Copy link to clipboard

Copied

Not sure if it will work the same on every web server, but try

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 01, 2006 Jul 01, 2006

Copy link to clipboard

Copied

LATEST
richdxb,
Just so that you know.... A page that redirects to another page automatically, is severly 'frowned on' by Search Engines, thus you may have the result of the entire site being ignored rather than forcing a specific page to show up in the search results.

Have you researched 'robots.txt'? You may be able to put some code in that file that instructs the google spider on what page to 'start with'.

Hope this helps

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation