Put your tips and tricks online - Share your knowledge! Login | Register
 
 
  Search     Advanced search
 

Home | Ask Question | Add tip | Questions | My tips | Recent tips & tricks | Suggest a category | FAQ | Forums

 
 
 
 Category : Home > Internet > Web Servers > Apache > mod_rewrite and .htaccess     

Using mod_rewrite to redirect from dom.com to www.dom.com


Normally you will want your users to browse to www.mydomain.com instead of mydomain.com. It is
good for search engine optimization to have one destination. It's also useful when you use
cookies to keep users logged on when they are accessing different subdomains i.e.
www.mydomain.com, shop.mydomain.com, forum.mydomain.com etc. You can use mod_rewrite to
achieve this. Put the following rule in your .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R]


NOTE: to use the above rule you must compile Apache with mod_rewrite. ISP's usually have
mod_rewrite enabled.


  Options
 
   del.icio.us  |  newsvine  |  digg  |  furl  |  google  |  yahoo  |  Ma.gnolia  |  vigillar  |  reddit  |  technorati  |  icerocket  |  pubsub

       Rate this tip:    

Start discussion or add comment to this tip

  Details
Tip reference : #31
views : 418
Added on : 10/26/05
Submited by : h8dk97
 
Send a message Send a message Printer friendly output Printer friendly output
Display this member's tips Display this member's tips (172)
 
 
<< Previous
 Most viewed tips 
  Databases > Oracle > Security : How to unlock Oracle user account  
  Operating Systems > Unix : How to kill Unix user session  
  Databases > Oracle > Performance Tuning : How to enable trace in Oracle  
  Databases > Oracle : Kill user session  
   
  All categories
Databases | Programming | Hardware | Operating Systems | Networking | Internet | ERP / CRM | Games & Multimedia | Graphics & Design | Miscellaneous | Office Software | TipLib FAQ
 
 

Home |  FAQ |  Terms of Use |  Privacy Policy

© 2005 tiplib.com