my url not redirect to www.

Discussion in 'PHP' started by dh86, Jun 21, 2012.

  1. #1
    i have this in my htaccess file and its not redirecting it to www. I have changed the domain to mydomain just to show you.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^MYDOMIAN\.COM$ [NC]
    RewriteRule ^(.*)$ http://www.MYDOMAIN.COM/$1 [R=301,L]
     
    dh86, Jun 21, 2012 IP
  2. Chuckun

    Chuckun Well-Known Member

    Messages:
    1,161
    Likes Received:
    60
    Best Answers:
    2
    Trophy Points:
    150
    #2
    Try this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yourdomain.com$
    RewriteRule ^(.*)$ "http\:\/\/www\.yourdomain\.com\/$1" [R=301,L]
    Code (markup):
    You've got your '\' in all the wrong places :p
     
    Chuckun, Jun 21, 2012 IP
  3. dh86

    dh86 Active Member

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #3
    someone please help i have tryed the above and this didnt work either my htaccess file has the above code in and nothing else is the htaccess ment to have a start and finish command
     
    dh86, Jun 21, 2012 IP
  4. Chuckun

    Chuckun Well-Known Member

    Messages:
    1,161
    Likes Received:
    60
    Best Answers:
    2
    Trophy Points:
    150
    #4
    Sounds to me like you don't have mod_rewrite enabled?

    Also, please don't PM me when I'm already involved with the topic >.<

    Chuck
     
    Chuckun, Jun 21, 2012 IP
  5. Estevan

    Estevan Peon

    Messages:
    120
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    0
    #5
    hello

    try this

    RewriteCond %{HTTP_HOST} !^www.site.com$
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301]

    Best
     
    Estevan, Jun 21, 2012 IP
  6. avinash gaud

    avinash gaud Member

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #6
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yoursitename\.com$ [NC]
    RewriteRule ^(.*)$ http://www.yoursitename.com/$1 [R=301,L]
    AddHandler application/x-httpd-php5 .html .htm
     
    avinash gaud, Jun 22, 2012 IP
  7. mparkar26

    mparkar26 Banned

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
     
    mparkar26, Jun 27, 2012 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    Technically you don't need to escape characters in the STRING part of the RewriteRule.
     
    NetStar, Jun 27, 2012 IP