301 redirect problem

by 4 replies
5
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//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 %{---_host} ^mydomain [nc]
rewriterule ^(.*)$ ------.mydomain /$1 [r=301,nc]


What i did wrong?
#programming #301 #problem #redirect
  • 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} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,NC]
  • Thanks!
    it's works
  • I also use this its work thanx for such a nice share.
  • here is good code to 301 redirect, write in .htaccess:

Next Topics on Trending Feed

  • 5

    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//mydomain