Reply to topic
Permanent redirection for .cfm to root
Tunç


Joined: 29 Jan 2007
Posts: 15
Reply with quote
Hi,

How can we do a permanent redirection (301) http://www.example.com/index.cfm to http://www.example.com ?

We are on a Windows 2003 VPS.

Thanks
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 570
Location: Harrisburg, PA
Reply with quote
Sure Can.

<cflocation url="http://www.example.com" statuscode="301">
Tunç


Joined: 29 Jan 2007
Posts: 15
Reply with quote
Jason101 wrote:
Sure Can.

<cflocation url="http://www.example.com" statuscode="301">


Thanks Jason. Do I put this on the index.cfm file?
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 570
Location: Harrisburg, PA
Reply with quote
Yes, but the only problem is, you will get stuck in an infinite loop since http://www.example.com/ and http://www.example.com/index.cfm are exactly the same.

If you don't specify a file name (and just hit the root), the default document is used (which is usually index.cfm)
Tunç


Joined: 29 Jan 2007
Posts: 15
Reply with quote
Jason101 wrote:
Yes, but the only problem is, you will get stuck in an infinite loop since http://www.example.com/ and http://www.example.com/index.cfm are exactly the same.

If you don't specify a file name (and just hit the root), the default document is used (which is usually index.cfm)


The reason i wanted do do it for SEO purposes. have a look at http://www.ragepank.com/redirect-check/ for example.com.

Potential problems on this site

* 4 pages returned a 200 response. This indicates potential for duplicate content problems. Ideally, only http://example.com OR http://www.example.com should return a 200 response.


I have managed to forward non WWW to www using IIS but forwarding index.cfm to root is the problem. I think i need to invest to Helicon's ISAPI rewriter as it did work on the trial program.
nathacof
Forum Admin

Joined: 24 Oct 2006
Posts: 192
Location: Dover, DE
Reply with quote
With PHP, I'd use the REQUEST_URI variable to determine what page your visitors are using, and if it finds the string index.cfm file, redirect the url without index.cfm ...

http://example.com/index.cfm -> http://example.com/
http://example.com/directory/index.cfm -> http://example.com/directory/

I'm not a coldfusion developer but couldn't this be accomplished in your Application.cfm with a CFIF, and CFHeader?

CGI Environment Variables
CFHeader

Just realized you IIS users don't have this environment variable. Perhaps PATH_INFO has the necessary information?
jamie
HostMySite Sales Rep
HostMySite Sales Rep

Joined: 19 Mar 2004
Posts: 858
Location: Newark, De
Reply with quote
A comment on the same page that Nate referenced says

As of CF 7 cgi.request_uri no longer works.

Instead, you will want to use these vars.

cgi.redirect_url
cgi.redirect_query_string


So those are what you'd need.
Permanent redirection for .cfm to root
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic