Zen Cart Logo
Forums / General Questions / putting redirect in my htaccess file

putting redirect in my htaccess file

Views: 1,662

Results 1 to 8 of 8
18 Mar 2013, 8:34 PM
#1
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

putting redirect in my htaccess file

i want to put in my htaccess file a redirect from non www inquiries to www. for my website..

for example, redirect all domain.com to https://www.domain.com

i have coding that will do that

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

but there is already existing coding in my htaccess that i don't want to mess up. coding for zen cart?? and for ceon_uri_mapping.. here is the coding already in there:

BEGIN CEON URI MAPPING REWRITE RULE

RewriteEngine On

Don't rewrite any URIs ending with a file extension (ending with .[xxxxx])

RewriteCond %{REQUEST_URI} !.[a-zA-Z]{2,5}$ [OR]
RewriteCond %{REQUEST_URI} .(html)$ [NC]

Don't rewrite any URIs for some, popular specific file format extensions,

which are not covered by main file extension condition above

RewriteCond %{REQUEST_URI} !.(mp3|mp4|h264)$ [NC]

Don't rewrite any URIs for some specific file format extensions,

which are not covered by main file extension condition above

Uncomment the following line to apply this condition! (Remove the # at the start of the next line)

#RewriteCond %{REQUEST_URI} !.(3gp|3g2|h261|h263|mj2|mjp2|mp4v|mpg4|m1v|m2v|m4u|f4v|m4v|3dml)$ [NC]

Don't rewrite admin directory

RewriteCond %{REQUEST_URI} !^/adminhiddenxxxxxx [NC]

Don't rewrite editors directory

RewriteCond %{REQUEST_URI} !^/editors/ [NC]

Don't rewrite logs directory

RewriteCond %{REQUEST_URI} !^/logs/ [NC]

Don't rewrite catalog directory

RewriteCond %{REQUEST_URI} !^/catalog/ [NC]

Don't rewrite tempEP directory

RewriteCond %{REQUEST_URI} !^/tempEP/ [NC]

Don't rewrite mobile

RewriteCond %{REQUEST_URI} !^/m/ [NC]

Handle all other URIs using Zen Cart (its index.php)

RewriteRule .* index.php [QSA,L]

END CEON URI MAPPING REWRITE RULE

since i know VERY LITTLE about htaccess coding, can someone please help me here.. btw, the admin directory is of course not real..

18 Mar 2013, 9:28 PM
#2
kobra avatar

kobra

Black Belt

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

Re: putting redirect in my htaccess file

This should be handled by adding the www to your configure.php files

Store side file

  define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');

Admin side file

  define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTP_CATALOG_SERVER', 'http://www.xxxxxxxx.com');
  define('HTTPS_CATALOG_SERVER', 'https://www.xxxxxxxx.com');
18 Mar 2013, 9:32 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: putting redirect in my htaccess file

lidlchris:

i want to put in my htaccess file a redirect from non www inquiries to www. for my website..

No need to do this. ZC handles canonical issues already with

<?php if (isset($canonicalLink) && $canonicalLink != '') { ?>
<link rel="canonical" href="<?php echo $canonicalLink; ?>" />
<?php } ?>

in the html_header.php files

And there's also no need to (or advantage in) re-writing URL's. If you think this may assist "SEO" then you are mis-informed. It has zero influence on "SEO".

18 Mar 2013, 9:34 PM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: putting redirect in my htaccess file

kobra:

This should be handled by adding the www to your configure.php files

Store side file

define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');

> Admin side file
> ```
  define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTP_CATALOG_SERVER', 'http://www.xxxxxxxx.com');
  define('HTTPS_CATALOG_SERVER', 'https://www.xxxxxxxx.com');

Yes... you decide whether to use www by configuring your URL as Kobra describes. As I said above, the canonical issue is largely solved by the php code in the header.

18 Mar 2013, 10:33 PM
#5
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Re: putting redirect in my htaccess file

kobra:

This should be handled by adding the www to your configure.php files

Store side file

define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');

> Admin side file
> ```
  define('HTTP_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTPS_SERVER', 'https://www.xxxxxxxx.com');
  define('HTTP_CATALOG_SERVER', 'http://www.xxxxxxxx.com');
  define('HTTPS_CATALOG_SERVER', 'https://www.xxxxxxxx.com');

ok, this didn't work BUT maybe it's because i'm using 'multi sites' mod.. but even then i went into the _config.php file for this site and set it to go to https://www.xxxxxx.com and yet when you type in xxxxx.com it does NOT redirect..

are you familiar with 'multi sites'??

18 Mar 2013, 10:35 PM
#6
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Re: putting redirect in my htaccess file

schoolboy:

No need to do this. ZC handles canonical issues already with

<?php if (isset($canonicalLink) && $canonicalLink != '') { ?> <link rel="canonical" href="<?php echo $canonicalLink; ?>" /> <?php } ?> ``` > > in the html_header.php files > > And there's also no need to (or advantage in) re-writing URL's. If you think this may assist "SEO" then you are mis-informed. It has zero influence on "SEO".

no, not doing it for SEO.. doing it for SSL so that i only need to use one version for my multi domain SSL.. don't want to use up 2 on a https://www.xxxxxx.com AND xxxxxx.com..

19 Mar 2013, 2:57 AM
#7
kobra avatar

kobra

Black Belt

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

Re: putting redirect in my htaccess file

set it to go to https://www.xxxxxx.com and yet when you type in xxxxx.com it does NOT redirect.
Click on anything - does it redirect??

19 Mar 2013, 4:07 AM
#8
lidlchris avatar

lidlchris

Zen Follower

Join Date:
Feb 2013
Posts:
345
Plugin Contributions:
0

Re: putting redirect in my htaccess file

kobra:

Click on anything - does it redirect??

yes it does.. :) thanks...