InfernoForums  

Go Back   InfernoForums > Technical Support > Knowledge Base / FAQ > Domains & DNS
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 18-08-2004, 05:06 PM   #1
IH-James
InfernoHost Staff Member
 
Join Date: Nov 2002
Location: Perth, Australia
Posts: 247
Send a message via ICQ to IH-James Send a message via AIM to IH-James Send a message via MSN to IH-James Send a message via Yahoo to IH-James
Default How can I make sure someone uses www.domain.com instead of domain.com

It is very easy to make sure that a user uses http://www.domain.com instead of just http://domain.com with a simple piece of PHP code placed at the top of every page.

PHP Code:
<?php
$server 
getenv("HTTP_HOST");

if (!
ereg("^www."$server)) {
    
// Assume no www. has been entered
    
Header ("Location: http://www.".$server."/");
    Exit;
     
}
?>
Alternatively, you can also use mod_rewrite in your .htaccess file. Put it inside your public_html directory in order for the changes to effect all files/directories.

Code:
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
Replace domain and .com as necessary.
__________________
James Collins
InfernoHost Manager
IH-James is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:27 PM.


Powered by vBulletin 3.6.5, Copyright ©2000 - 2003, Jelsoft Enterprises Limited.