Why is CS Cart Using 302 Instead of 301 Redirect

Hello All,

We recently moved hosting and in the process changed from the non-www sub-domain to the www sub-domain. What I discovered is that changing the configuration in CS Cart admin settings will automatically redirect to the current one (ie. from non-www to www, and vice versa). This is a good thing. However, CS Cart (at least the version I have 2.0.8 ) is doing so with a 302 Moved Temporarily header. This causes search engines like Google to never update their index to our new URL scheme and more.



I’ve tried modifying config.php and change the line



```php define(‘CONTROLLER_STATUS_REDIRECT’, 302); ```

to

```php define(‘CONTROLLER_STATUS_REDIRECT’, 301); ```



and this has yielded no change. Not sure if CONTROLLER_STATUS_REDIRECT is even used in such situation.



I’m also sure the non-WWW to WWW redirect is not done in the .htaccess file, so I’m at a lost as to how to go about making CS Cart do the redirect with a 301. Can someone check to see if their redirects (either way) is using a 302 or 301 and what version? Does anyone have any idea how to fix this issue?



Appreciate all the help I can get.



Jimmy

Hello Jimmy,



When a page is redirected using 301 Redirect, Google indexes both pages (a page from which a customer should be redirected and a page to which a customer should be redirected). It can cause the issue that Google can index the same page having two links (e.g. [url]Default title | Domain.com and http://domain.com/page.html). Google will consider it as a duplicate content issue as long as two links refer to a single page. That is why 302 Redirect is used in CS-Cart. It makes Google index only a page to which a customer should be redirected.





Pavel Zyukin

CS-Cart Support team

The above just sounds wrong. The essential difference between a 301 and a 302 redirect is that a 301 tells a spider that the URL has moved PERMANENTLY whereas a 302 should be used if a URL has moved TEMPORARILY.



It follows that Google would not, should not index both old and new locations if a 301 is used - that is the whole point of using one.

I think you're confusing what's going on…

If you reference your site via mydomain.com and you have your config.local.php file set to use www.mydomain.com then it will probably use a 302 since the DNS environment and the storefront should be configured the same. In this case, you have mydomain.com and www.mydomain.com both resolving to the same IP address. If you want to use a 301, you should make an entry in your .htaccess file to redirect to wwww.mydomain.com with a 301 if only mydomain.com is used. No reason to have the cart doing work that should be done via Apache layer.