homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Problems Redirecting non www to www.
problems redirecting non www to www
stayce

5+ Year Member



 
Msg#: 3829224 posted 3:06 am on Jan 19, 2009 (gmt 0)

I have been at this for a few hours.
I want to direct all visitors that go to my site via:
http://example.com

to be redirected to http://www.example.com.

I tried to do this myself by going into my Control Panel (I use Pappashop's hosting service). In Control panel I was able to assign this redirect, but I realized I needed to alter my .htaccess file.

I did this after finding the (supposedly) appropriate code online, but it did not work. I know I uploaded the revised file correctly so it wasn't an error like that.

I am at a loss: my site will not come up now when i type in either URL (www.example.com or example.com).
I appreciate any help in advance. losing $$$ as I type...

 

diddlydazz

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3829224 posted 3:38 am on Jan 19, 2009 (gmt 0)

hi stayce

welcome to WebmasterWorld :o)

try this code

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

hope this helps

dazz

stayce

5+ Year Member



 
Msg#: 3829224 posted 3:58 am on Jan 19, 2009 (gmt 0)

thank you!
i havent tried it yet, but wanted to ask if it where it went.
this is what i have at the beginning:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

so, should i put it directly under:
RewriteEngine On

?

stayce

5+ Year Member



 
Msg#: 3829224 posted 4:01 am on Jan 19, 2009 (gmt 0)

ok i went ahead and tried it directly under:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

it didnt work. any other ideas?
thank you so much for the help!

diddlydazz

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3829224 posted 4:15 am on Jan 19, 2009 (gmt 0)

could you post your entire .htaccess file?

stayce

5+ Year Member



 
Msg#: 3829224 posted 6:17 am on Jan 19, 2009 (gmt 0)

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule category/new(.*).htm$ catalog.htm?new=yes&page=$1
RewriteRule category/new.htm$ catalog.htm?new=yes

RewriteRule category/sale(.*).htm$ catalog.htm?sale=yes&page=$1
RewriteRule category/sale.htm$ catalog.htm?sale=yes

RewriteRule category/all(.*).htm$ catalog.htm?all=yes&page=$1
RewriteRule category/all.htm$ catalog.htm?all=yes

RewriteRule category/featured(.*).htm$ catalog.htm?featured=yes&page=$1
RewriteRule category/featured.htm$ catalog.htm?featured=yes

RewriteRule category_(.*)/(.*)/(.*).htm$ catalog.htm?category=$1&page=$2
RewriteRule category_(.*)/(.*).htm$ catalog.htm?category=$1

RewriteRule item_(.*)/new/(.*).htm$ catalog.htm?item=$1&new=yes
RewriteRule item_(.*)/all/(.*).htm$ catalog.htm?item=$1&all=yes
RewriteRule item_(.*)/sale/(.*).htm$ catalog.htm?item=$1&sale=yes
RewriteRule item_(.*)/featured/(.*).htm$ catalog.htm?item=$1&featured=yes

RewriteRule item_(.*)/(.*)/(.*).htm$ catalog.htm?item=$1&catid=$2
RewriteRule item_(.*)/(.*).htm$ catalog.htm?item=$1

RewriteRule article_(.*)/(.*).htm$ articles.htm?article=$1

</IfModule>
AddType application/x-httpd-php .php .htm .htmlRewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "http\:\/\/www\.example\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/" [R=301,L]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved