Con la funcion
Primero la lees en php.net
Luego buscas $_SERVER['REQUEST_URI'] y lo lees
Luego te pillas la funcion header()
Y ahora si haces tu script:
Evaluas asi: if(eregi('www.',$_SERVER['REQUEST_URI']))...
Y haces el header:
header('location:'.eregi_replace('www.','',$_SERVE R['REQUEST_URI']));