3

I want to redirect https to http for almost all pages, except for checkout, cart and account. Especially to improve speed.

How do I define that inside my htaccess?

All my rewrite rules in htaccess:

RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/customer/account/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteCond %{REQUEST_URI} !^/wishlist/
RewriteCond %{REQUEST_URI} !^/ebizautoresponder/
RewriteCond %{REQUEST_URI} !^/admin/dashboard/index/key/
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

##### Block unwanted Crawler Bots that clog your server #####

RewriteCond %{HTTP_USER_AGENT} MJ12bot
RewriteRule .* - [F]
RewriteCond %{HTTP_USER_AGENT} 80legs [NC]
RewriteRule ^ - [F]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

I use these settings for secure and unsecure:

enter image description here

  • 2
    why do you need htaccess redirects. Magento should handle the redirects automatically. – Marius Nov 4 '15 at 11:47
  • Do you want to do via htacessess only ? you can do it magento way in file: / app /code/core/Mage/Checkout/etc/config.xml find: <frontend> <secure_url> and insert: <checkout_cart>/checkout/cart</checkout_cart> So it looks like this: <frontend> <secure_url> <checkout_cart>/checkout/cart</checkout_cart> <checkout_onepage>/checkout/onepage</checkout_onepage> <checkout_multishipping>/checkout/multishipping</checkout_multishipping> </secure_url> – Vishwas Bhatnagar Nov 4 '15 at 13:27
  • @Marius No the problem is that Magento does not preform this correct. Because all normal pages are available trough http and https. And it is not redirecting correct to https on checkout – Henk Z Nov 4 '15 at 13:55
  • @Jelle. I see. I misunderstood your question. I though you wanted the other way around. Sorry for butting in then. – Marius Nov 4 '15 at 13:57
  • 1
    You might want to check on the concept of offloading. Having a proxy in front of your Magento that handles SSL is what we call SSL offloading. ehow.com/facts_7519825_ssl-offloading.html The impact of SSL is neglectable anyways, look at it as a small drop in a whole pond. If you want performance increase look into your code both backend and frontend. If you want to go even faster, use Varnish. Going full SSL is also better for SEO as @MilanSimek stated... – Toon Van Dooren Nov 10 '15 at 10:38
5

What you have so for should work pretty well. The actuall redirect part I've added below

RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/customer/account/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteCond %{REQUEST_URI} !^/wishlist/
RewriteCond %{REQUEST_URI} !^/ebizautoresponder/
RewriteCond %{REQUEST_URI} !^/admin/dashboard/index/key/
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • Thanks. But the checkout redirects to domain.com/index.php – Henk Z Oct 27 '15 at 15:39
  • Did you set the right safe and unsafe base urls in Magento backend? – Sander Mangel Oct 27 '15 at 15:41
  • Yes I did, these settings are correct. Also for the customer account, it redirects to to domain.com/index.php – Henk Z Oct 27 '15 at 15:43
  • See my safe and unsafe base urls settings, is this correct? Off course I removed my domain. – Henk Z Oct 27 '15 at 17:32
  • Can you update your question with all of you rewrite rules in the htaccess? – Sander Mangel Nov 5 '15 at 15:33
1

As I got from the comments, you are worrying about duplicate content.

1.Duplicate content should not be an issue for the admin pages ;

2. You should actually serve pages which belong to the customer or checkout pages via https as this is a matter of security. I don't see a duplicate content problem if those pages are always served via https which is the case in the Magento default configuration. If http and https is enabled, those pages will always be served via https only.

  • Thanks for the reply. I do know the reason to serve some pages over https. But I want to serve all other pages only over http. Also when these pages are requested over https, the shop should redirect the user to http. But I can't find a way to redirect always to http and only in the cart and checkout to https. – Henk Z Nov 5 '15 at 14:56
  • 2
    Actually thats the default behaviour in Magento?! If the option "Use secure URLs in Frontend" is enabled, customer account and checkout will be redirected from http to https, the rest is still running on http. – Anna Völkl Nov 5 '15 at 17:39
  • And for the admin area, enable "Use secure URLs in Admin" – Anna Völkl Nov 5 '15 at 17:39
  • Correct, but all these other pages are not redirecting to http, when navigating to https. Because that is not how it works default on Magento. – Henk Z Nov 5 '15 at 17:40
  • 1
    http and https versions of your page count as 'non-malicious' duplicate content: support.google.com/webmasters/answer/66359?hl=en. So no need to worry about that for SEO purposes – Milan Simek Nov 7 '15 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.