Zen Cart Logo
Forums / General Questions / .htaccess Redirect does not work

.htaccess Redirect does not work

Views: 1,214

Results 1 to 5 of 5
20 Feb 2011, 3:12 PM
#1
ms_x avatar

ms_x

Zen Follower

Join Date:
Mar 2010
Posts:
196
Plugin Contributions:
0

.htaccess Redirect does not work

Hi,

I have a problem with redirecting mysite
from http://mysite.com to
http://www.mysite.com. I did it using CPanel, it did not work at all.

I have 4 domain names pointing to the same site mysite.com. mysite.com is promary domain.

I tried to redirect using .htaccess file. Before it looked like this:

RewriteEngine on

Use PHP5 Single php.ini as default

AddHandler application/x-httpd-php5s .php
RewriteCond %{HTTP_HOST} ^otherproducts.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.otherproducts.com$
RewriteRule ^/?$ "http://mysite.com" [R=302,L]

RewriteCond %{HTTP_HOST} ^otherurl.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.otherurl.com$
RewriteRule ^/?$ "http://mysite.com" [R=302,L]

RewriteCond %{HTTP_HOST} ^otherurltest.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.otherurltest.com$
RewriteRule ^/?$ "http://mysite.com" [R=302,L]

and after I changed it, it looked like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mysite.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

And it worked but just for few hours. Today,trying to acces my site, I got
blank page and changed .htaccess back

again.

So the problem is still there. maybe someone knows how to solve it?

21 Feb 2011, 4:17 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: .htaccess Redirect does not work

What are your configure.php files set for?

22 Feb 2011, 3:04 AM
#3
ms_x avatar

ms_x

Zen Follower

Join Date:
Mar 2010
Posts:
196
Plugin Contributions:
0

Re: .htaccess Redirect does not work

it stands for http://www.mysite.com withour SSL and for
https://www.mysite.com with SSL

22 Feb 2011, 4:33 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: .htaccess Redirect does not work

If mysite.com is your primart cpanel domain

Just park the others in cpanel - - no redirection required

Clean up your other attempts first

22 Feb 2011, 4:33 PM
#5
cadyman avatar

cadyman

New Zenner

Join Date:
Oct 2010
Posts:
27
Plugin Contributions:
0

Re: .htaccess Redirect does not work

If the HTTP_SERVER constant is set with https://www.name.com all links will be like that but if you want to redirect the name.com to the https://www.name.com can insert in the index.php a line like this

if( $_SERVER['HTTP_HOST'] == "name.com") { header("Location: http://www.name.com/"); }

To me work fine :) if you don`t have 2 domain that point to the same root folder.