WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-10-2005, 01:48 PM
inflectionpt inflectionpt is offline
WebProWorld New Member
 

Join Date: Oct 2004
Location: San Francisco, CA
Posts: 10
inflectionpt RepRank 0
Default ModRewrite: How to redirect [domain].com to www.[domain].com

I need to redirect as suggested in the subject. I actually found some code but it seems to be doing 302s. Can someone help me out and post the code for mod rewrite that does this? The current code I have is the following:

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

Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-10-2005, 11:20 PM
Deep13's Avatar
Deep13 Deep13 is offline
WebProWorld Veteran
 

Join Date: Dec 2003
Location: India
Posts: 306
Deep13 RepRank 0
Default

try this and see

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

you can also check your headers here

Regards
Deep
Reply With Quote
  #3 (permalink)  
Old 02-12-2005, 08:12 AM
OleTom OleTom is offline
WebProWorld Member
 

Join Date: Jan 2004
Location: Out There Somewhere
Posts: 37
OleTom RepRank 0
Default

Code:
<HEAD><meta http-equiv="refresh" content="0; URL=http://www.yoursite.com"></HEAD>
This will work if you name index.html
__________________
Life is Good,
OleTom
Consumers-Voice.com
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: domaincom, modrewrite, redirect, wwwdomaincom



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
Trackbacks are On
Pingbacks are On
Refbacks are On



Search Engine Friendly URLs by vBSEO 3.0.0