Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Earlier i have posted this question : http://stackoverflow.com/questions/36104047/how-to-redirect-all-http-requests-to-https-on-magento but didn't get any reaction.

Here is my site URL : www.trendy-mode.nl it will redirect you to : https://www.trendy-mode.nl/

Now problem is menu link or any other sub-links are not redirect with https://

EX:
There is menu like - NIEUW | KLEDING | SCHOENEN | ACCESSOIRES etc.
If you click on NIEUW menu, a new page will be open but not redirect with https://

I have tried a lot .htaccess tweaks but not works. Anybody here to help me on this?

Thank you in advance!

share|improve this question
up vote 9 down vote accepted

Changing the unsecure base url to https will change all links and redirect non-https requests to https://example.com/ (the home page), because that's what Magento does when the base URL validation fails.

So this is a good start but to also redirect http://example.com/foo/ to https://example.com/foo/ you need to do it via webserver redirect.

For example, add the following code at the top of your .htaccess:

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Or if you use a reverse proxy like Varnish:

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

This is because the requests from Varnish to Magento will be without SSL (HTTP), but Varnish sets the X-Forwarded-Proto header to "https" if the original request was made with SSL (HTTPS).

share|improve this answer
    
@Abhishek I just tested your site and since it's not working yet - Fabians instructions above are correct .. but should also say that these 2 lines should be added to .htaccess file in the root of your magento installation but NOT at the top (generally) but as mentioned below, just after RewriteEngine On . The way I have done it is just slightly different in that my second line reads; RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] – Peter Svegrup Mar 22 at 17:47

For completeness we also do a very similar thing to what fschmengler has suggested with some additions;

RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_METHOD} !=POST
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

We place this inside the section of the .htaccess just below RewriteEngine On

share|improve this answer

I think the easiest way would be to change the non-secure base url to https since magento then redirects all "non-secure" requests to this url and also generates the links with this url.

you can change the base url under system -> configuration -> general -> web

share|improve this answer
    
Thank you for your replay.. i did it but now if you open this link : www.trendy-mode.nl/damesschoenen/slippers it will jump you to homepage. have any solution? – Abhishek Kumbhani Mar 20 at 17:19
    
hm thats weird :) Did you mind the trailing slash in the base url? I think this matter is really interesting as it will be most likely beeing seo relevant in the future (or maybe already now?) to have the whole page using https. I can ask my colleague tomorrow since he had done this for a magento shop already – David Verholen Mar 20 at 17:26
    
although fschmengler's solution should work I think, the answer of @Michael seems like the right way to do this if it works – David Verholen Mar 20 at 18:19
    
Well fschmenglers answer is not false. I am just annoyed of Magentos update strategy as it touches .htaccess and index.php but not local.xml. So it's more 'update save' imho – Michael Mar 20 at 21:38

Set your base url for secure and unsecure in the backend. Set yes on use secure url in frontend in the backend.

Then edit your app/etc/local.xml and include this

<?xml version="1.0"?>
<config>
  <frontend>
     <secure_url>
      <all>/</all>
     </secure_url>
   </frontend>
</config>

Or at least paste the XML tree frontend and lower in between the config tags.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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