Hey there, I have a website setup so it directs non-www versions of pages to the www version. For example, the following url: http://green-watch.org/businesses-going-green.cfm redirects the user to the following url: http://www.green-watch.org/businesses-going-green.cfm It uses the following code: <cfset IndexOfOccurrence=Find("www.green-watch.org", #cgi.server_name#)> <cfif #IndexOfOccurrence# EQ 0> <cfset myLink = 'http://www.#myDomain##cgi.script_name#?#cgi.query_string#'> <cflocation url="#myLink#" addtoken="no"> </cfif> Code (markup): My question is how do search engines see the non-www version of the webpage? Is there something I should do to the non-www version so search engines wont index or cache the non-www version and still index and cache the www version? Thanks in advance for any information. Sincerely, Travis Walters
I would suggest that you use the 301 redirect instead of using a script to do it. The point of doing the 301 is so they won't see the non-www version. Everytime a user or a bot goes to your site they get a (or many) HTTP response codes...a 301 redirect tells the bot or browser that all the stuff on that page has been PERMANANTLY moved to another page and they should use that one. When Googlebot encounters a 301, they throw it to the back of the pack and crawl it later. With all of that said, you are doing the right thing...here is another thing you can do to help with canonicalizing you page and making sure Google and other SE's are on the same page: Go into Google Webmaster Tools and let them know the version of the page you perfer...in your case, the www version. Same thing for any other engine that has that feature.
PS: Here is what you would need to use for your redirects... This code will redirect: http://yoursite.com/whatever.cfm to http://www.yoursite.com/whatever.cfm RewriteEngine on RewriteCond %{HTTP_HOST} ^yoursite.com$ RewriteRule ^whatever\.cfm$ "http\:\/\/www\.your\site\.com\/whatever\.cfm" [R=301,L] Also, I am not too sure the affect the CFM format would have on anything, that is coldfusion, right? If so, I am sure Google has no problem with them as they sleep with Adobe.com...lol PS: You need to have apache server for that to work, if you have a windows server it will not
Greetings, Thank you for the assistance in this matter. I updated my code to the following for redirects: <cfset IndexOfOccurrence=Find("www.green-watch.org", #cgi.server_name#)> <cfif #IndexOfOccurrence# EQ 0> <cfset myLink = 'http://www.#myDomain##cgi.script_name#?#cgi.query_string#'> <cfheader statuscode="301" statustext="Moved permanently"> <cfheader name="Location" value="#myLink#"> </cfif> Code (markup): I am using a windows box with coldfusion. Hope this helps somebody else that has this issue one day. Sincerely, Travis Walters
Since you've included the 301 HTTP header in the Coldfushion code, you should be fine, Travis. Good luck with the redirect!