BigNoseBird.Com- home Small Logo
The 508 compliant Guide to 
       Big Nose Bird
BACK
WARNING: Be very careful editing your server configuration or .htaccess files. Even a minor typographical error can make your site unusable! Always make a backup copy of any file so you can recover quickly.

FORCING domain.com TO www.domain.com USING MOD REWRITE ENGINE AND .HTACCESS

If your site can be accessed as both http://www.domain.com/ as well as http://domain.com/ and are having trouble with things such as cookies on the Netscape browser*, here is a little rewrite rule you can place in your httpd.conf or on a per directory basis using .htaccess.

Here is what happens. When you request a page such as http://domain.com/x.html, the rewrite engine checks to see if the HTTP_HOST does not match the fully qualified domain name (FQDN) which in this case is www.domain.com. If they do not match, the engine rewrites the URL with the SERVER_NAME value, so make sure that your SERVER_NAME in your httpd.conf is the FQDN.

   RewriteEngine On
   RewriteCond %{HTTP_HOST} !www.domain.com
   RewriteRule ^.*$     http://%{SERVER_NAME}%{REQUEST_URI} [R]

*About the Netscape Cookie Problem: If you issue a cookie from www.domain.com using a string such as "domain=.domain.com", it cannot be read by domain.com, fred.domain.com, and so on. MSIE does not have this trouble. If you force all your URLs to start with www. and issue the cookie using domain=www.domain.com, this resolves the problem.



Find or Give Help on the BBS
 
Home Top E-Mail
If it looks great, it's by Christine
Some Fine Print
© 1997-2003 BigNoseBird.Com®, Inc. All rights reserved. All other trademarks are the sole property of their respective owners. The products that we recommend are only ones that we use. We have no relationship with any of the authors or their companies. We cannot assume responsibility for their ultimate performance or lack of same. We also cannot assume responsibility for either any programs provided here, or for any advice that is given since we have no control over what happens after our code or words leave this site. Always use prudent judgment in implementing any program- and always make a backup first! For further information, please read our Privacy Statement. We can be contacted at webmaster@bignosebird.com.


<reallybig.com>
Web Builder Network Portal
Advertise
on the
Reallybig.com
Network
BigNoseBird Newsletter
Subscribe
Un-Subscribe


Sign up today to receive our low volume newsletter. Tips, tricks, news, and whatever else crosses our minds.
Back Issues
Privacy Statement