Kanał Rss Kanał Rss
Kanał Atom Kanał Atom

Redirect in JS breaks Google/Bing "Cached" links

wersja drukowalna wersja Microsoft Word wersja HTML

We added a fix into ipb.js for a problem with the Facebook integration, the following code:

/**
		 * @link	http://community.invisionpower.com/tracker/issue-23320-status-updates-hook-breaks-under-certain-circumstances/
		 */
		var _requestedHost	= location.protocol + '//' + location.host;
		
		/* Without www */
		if ( _requestedHost.match( /^http:\/\/www/ ) && !ipb.vars['base_url'].match( /^http:\/\/www/ ) )
		{
			ipb.vars['base_url']	= ipb.vars['base_url'].replace( /^http:\/\//, 'http://www.' );
			ipb.vars['board_url']	= ipb.vars['board_url'].replace( /^http:\/\//, 'http://www.' );
		}
		
		/* With www */
		if ( ipb.vars['base_url'].match( /^http:\/\/www/ ) && !_requestedHost.match( /^http:\/\/www/ ) )
		{
			location.href = location.href.replace( /^http:\/\//, 'http://www.' );
		}


However, that same code - in the case that your "base_url" setting includes a www. - prevents the Google/Bing cached pages from showing up, as it redirects you to www.<their cache url>

This check should really be done in PHP if it needs to redirect, to prevent things like this happening. Would also be good from an SEO perspective to ensure that users are redirected to the "real" board URL if they go to the wrong version. :)

czw, 29 lipiec 2010

Komentarze:

Brak komentarzy

Imię/Nick:

Adres email:

Strona WWW:

Treść Komentarza: