301 redirect problem

Discussion in 'Programming' started by ztume, Feb 15, 2012.

  1. #1
    Hi,
    so i want redirect non www to www. But something is going wrong. When i write my url without www. it´s redirect to: mydomain/index.php/http:/mydomain




    .htaccees file looking like this:


    AddType application/x-httpd-php53 php53 php
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
    </IfModule>
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^mydomain [nc]
    rewriterule ^(.*)$ http://xxx.mydomain /$1 [r=301,nc]


    What i did wrong?
     
    ztume, Feb 15, 2012 IP
  2. Estevan

    Estevan Peon

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

    use this

    RewriteEngine on

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

    off course replace site.com for your domain

    Best
     
    Estevan, Feb 15, 2012 IP
  3. Ultrabooked

    Ultrabooked Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or this:
    RewriteCond %{HTTP_HOST} ^site.com [NC] 
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
    Code (markup):
     
    Ultrabooked, Feb 16, 2012 IP