Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   301 redirect problem (https://www.warriorforum.com/programming/542125-301-redirect-problem.html)

ztume 15th February 2012 12:56 PM

301 redirect problem
 
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?

Nochek 15th February 2012 01:06 PM

Re: 301 redirect problem
 
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]

ztume 15th February 2012 01:50 PM

Re: 301 redirect problem
 
Thanks!
it's works :)

Fiverivers 17th February 2012 11:33 PM

Re: 301 redirect problem
 
I also use this its work thanx for such a nice share.

bbleo 20th February 2012 07:59 AM

Re: 301 redirect problem
 
here is good code to 301 redirect, write in .htaccess:
Quote:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) example2.com/$1 [R=301,L]


All times are GMT -6. The time now is 11:36 AM.