[eluser]skunkbad[/eluser]
[quote author="hugle" date="1262003641"][quote author="skunkbad" date="1261989530"]Why not use .htaccess ?[/quote]
Hi
can you give .htaccess example?
[/quote]
Example (replace mywebsitedomain with your own):
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mywebsitedomain\.com [NC]
RewriteRule ^(.*) http://www.mywebsitedomain.com/$1 [R=301]
If you can use this, the benefit would be that Apache (the web server) would perform the redirect without PHP processing a script. I think theoretically this means a faster redirect/response. Like Brian said, you might not be able to use .htaccess files, so this might not work for you. Most of my sites are powered by LiteSpeed, and I use .htaccess, so using .htaccess isn't exclusive to Apache, but the vast majority of web servers out there are Apache.