Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Closed Thread
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 05-08-2012, 10:09 AM
Junior Member
 
Join Date: 11-03-11
Posts: 3
iTrader: 0 / 0%
Trouble redirecting non www urls to www

I'm trying to make non www urls to my site redirect to www urls. When I place the command below (replacing mysite.com with my actual domain of course) in the .htaccess my site cannot be accessed at all. Am I doing something wrong?
Code:
RewriteEngine On RewriteCond %{HTTP_HOST} !^mysite.com$ [NC] RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

Last edited by HTMLBasicTutor; 05-08-2012 at 07:19 PM.
 
  #2 (permalink)  
Old 05-08-2012, 07:24 PM
HTMLBasicTutor's Avatar
Super Moderator
 
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 18,070
iTrader: 5 / 100%
Mine is a tiny bit different
Code:
RewriteEngine On RewriteCond %{HTTP_HOST} ^mysite.com$ [NC] RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
No ! in the first line.

If that doesn't work, what hosting company are you using so we can try and find the right way for that particular company. Sometimes what works for one host doesn't always work for another.
__________________

HTML Basic Tutor - Learn how to code for better SEO
Basic Computer Information - Computer & internet basics for website owners

SEO troubleshooting and review services available. - Pm me.
 
  #3 (permalink)  
Old 05-09-2012, 08:01 AM
Junior Member
 
Join Date: 11-03-11
Posts: 3
iTrader: 0 / 0%
Quote:
Originally Posted by HTMLBasicTutor View Post
Mine is a tiny bit different
Code:
RewriteEngine On RewriteCond %{HTTP_HOST} ^mysite.com$ [NC] RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
No ! in the first line.

If that doesn't work, what hosting company are you using so we can try and find the right way for that particular company. Sometimes what works for one host doesn't always work for another.
Thanks for responding. Somebody gave me this code yesterday and it worked.
Code:
RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC] RewriteRule .? http://www.mysite.com%{REQUEST_URI} [R=301,L]
 
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting old URLs dtommy79 Coding Forum 6 12-08-2011 03:17 PM
WTS php script - Convert external URLs to internal URLs xmsmmgrs Content 2 01-28-2009 09:53 PM
how can Convert Dynamic Urls to SEO Friendly URLs SEOAmit SEO Forum 10 06-09-2008 02:36 AM
redirecting duplicate urls jbob SEO Forum 4 02-24-2008 01:22 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:00 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.