DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PHP For Removing Www From Request And Redirecting. (Useful For System.security.allowDomain Issues)

01.22.2008
| 2230 views |
  • submit to reddit
        
<?
	// if www.domain.com, redirect to domain.com
	if (strtolower(substr($_SERVER['HTTP_HOST'], 0, 3)) == "www") {
		header("Location: http://rgcreative.com" . $_SERVER['REQUEST_URI']);
	}
	
	// Full path to current URL (including query string)
	//echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>