Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

htaccess redirect for new directory structure and https

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-16-2016, 08:41 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default 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.
__________________
Core version: 5.5.xx
Reply With Quote
  #2  
Old 08-17-2016, 01:06 AM
 
kevinrm kevinrm is offline
 

X-Wizard
  
Join Date: Aug 2003
Posts: 1,003
 

Default 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.
__________________
X-Cart 5.4.1.39 Live
PHP 7.4.33
5.5.5-10.3.38-MariaDB MariaDB
Apache 2.4
CENTOS 7.8 64Bit Single Quad-Core E3-1241v3 3.4Ghz 8M 1600 w/ HT
32GB RAM 2x 512GB Samsung 850 Pro SSD RAID 1
Reply With Quote
  #3  
Old 08-18-2016, 03:45 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default 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.
__________________
Core version: 5.5.xx
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:29 PM.

   

 
X-Cart forums © 2001-2020