First to admit that I do not know php well at all. I know how to do this in asp:
<% Select Case Request.ServerVariables("HTTP_HOST") Case "example.co", "www.example.co" Response.Redirect "http://www.example.com/index.asp" End Select %>
but have no clue how to write it in php for placement in the <head>.
The above code is for a 302 redirect. Add a preceding HEADER directive to set it as a 301 redirect.
The example also redirects to a named index file. You should redirect to bare folder ending with a trailing slash. The DirectoryIndex directive will take care of the rest.
rocknbil
4:19 pm on Mar 20, 2012 (gmt 0)
This should really be at the server level and not in programming. Is it still a Windows server, and at least IIS 7?
Play with this [learn.iis.net], what you want is a slight modification of a canonical rewrite. It took M.S. forever to finally come around to the importance of rewrites and add a compatible module into their server software, but it works similarly to mod_rewrite.