phpurl-rewriting

how do i strip out the WWW in my url using php


so i want to do an external permanant redirect (301) from http://www.creya.com to http://creya.com.

i am not using apache but rather, abyss web server and i can't figure out the url rewrite rules. but i believe i could also do this at the app level with php.

i think wordpress does do this. i set http://creya.com/blog as your blog url and try to hit http://www.creya.com/blog; it redirects to http://creya.com/blog. i want to do the same thing.

any ideas how i can make this hijacking happen?


Solution

  • This should do it-

       if($_SERVER['SERVER_NAME']!='creya.com')
        {
            Header("HTTP/1.1 301 Moved Permanently");
            Header("Location: http://creya.com".$_SERVER['REQUEST_URI']); 
        }