Hi everyone .. I was told that I must do a redirection for my http://myadressexample.net to http://www.myadressexample.net to prevent SE from indexing two different sites .. sounds good .. but how to do that ? I have a cpanel with redirection options , but when I triend to make that , I redirected every page on my site to http://www.myadressexample.net So how to do this the right way ? thanks .. Toon
use this code at your site index page source code in head "<script language="JavaScript" type="text/JavaScript" src="redirection.js"></script> " after that create a page http://www.xyz.com/redirection.js in which put this code url = window.location.href; var valid = "w" var len=url.length; var chk=url; for(i=0;i<len;i++) { x = chk.charAt(i) if(!(valid.indexOf(x) == -1)) { //found var red = "no" i = len; } } if(red != "no") { location.href=("http://www.xyz.com"); }
I would NOT recommend trying to use javascript to fix canonical issues (which is what you have if your pages can be accessed with and without www). Search engine crawlers do not execute javascript so they will never see the redirect above. The above javascript might fix it in the browser for site visitors, but they could care less whether you have canonical issues or not. It's the spiders/crawlers you need to fix it for. You need to use Mod Rewrite or something like it to implement 301 redirects. You will have access to this if you're hosted on an Apache web server. You should be able to create a .htaccess file in the root of your web with something like the following to redirect: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^myaddressexample\.net$ [NC] RewriteRule (.*) http://www.myaddressexample.net/$1 [R=301,L] I'm just winging this... haven't tested it and it's late... You can Google "fix canonical issues with mod rewrite" to get more examples.