X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   htaccess redirect for new directory structure and https (https://forum.x-cart.com/showthread.php?t=74320)

xgarb 08-16-2016 08:41 AM

htaccess redirect for new directory structure and https
 
We're going live with the new x5 store soon and some of the URLs have changed so we need to set up 301 redirects.

We also want to make the entire store https. This also requires 301 redirects to avoid dropping pages in Google.

I have the following. Will this make every request https and also redirect the categories?

Code:

RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI}
RewriteRule  ^category-path/  /new-root-cat/category-path/  [R=301,L]
RewriteRule  ^category-path2/  /new-root-cat/category-path2/  [R=301,L]


I'm not sure if the second line should be 301 as well to cover the categories that don't match the following rewrite rules.

kevinrm 08-17-2016 01:06 AM

Re: htaccess redirect for new directory structure and https
 
If you want to make your life WAY easier, there is a re-direct module for XC5 that works really good.

xgarb 08-18-2016 03:45 AM

Re: htaccess redirect for new directory structure and https
 
Thanks for the tip. We bought - http://market.x-cart.com/addons/redirects-by-Nova-Horizon.html

Here's their response, to a question I asked, for anyone looking at this..

The module uses an internal X-cart system, it does not modify .htaccess at all. All your entered redirects are stored in the database, and when X-cart tries to load an invalid page it checks to see if a redirect exists for that path. All redirects created are 301 redirects.


My current thinking for the http to https part is to have this in htaccess as the first rule:

Code:

  RewriteCond %{HTTPS} !=on
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]


So anything that's not https gets a permanent redirect and then after that has happened any other rules are run. We'll probably put some redirects in htaccess and then use the extension when we catch stray 404s showing.


All times are GMT -8. The time now is 04:50 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.