you can redirect with location('header:') if $_ENV['HTTP_HOST'] does not
start with "www."
try something like:
if (isset($_ENV['HTTP_HOST']) && substr($_ENV['HTTP_HOST'],0,4)!='www.')
header('location: http://www.'.$_ENV['HTTP_HOST']);
of course it is much cleaner to configure the host directly in
apache/conf/httpd.conf
----- Original Message -----
From: "Mian Waqas" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, July 04, 2006 9:13 AM
Subject: [php-list] www in URL
Hi Friends,
My client requires that his site should open only using www in the URL
like http://www.sitename.com/anypage.php and no one should be allowed
to access it using this URL http://sitename.com/anypage.php. If some
one type this URL http://www.sitename.com/anypage.php than it should
automatically convert to http://www.sitename.com/anypage.php
Is it possible? Can I do it in PHP? Can I do it in .htacces file?
Which way is better?
Waiting for your response.
Thanks,
Waqas
------------------------ Yahoo! Groups Sponsor --------------------~-->
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/HKFolB/TM
--------------------------------------------------------------------~->
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/