I want to redirect all http
urls to https
in magento, but for front-endonly. In magento we have a setting to use secure urls for front-end as explained in this link: https://www.siteground.com/tutorials/magento/magento_ssl.htm but that applies to only pages shown after login or checkout.
I have applied following code in my .htaccess file:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
It is working ok, but it is redirecting Admin panel urls to https
as well. I don't want that, I want only front-end to secure not the admin panel urls.
Please check and advise if we can do such thing in magento?
First remove your rule.
Then, as per this reference go to your admin area. Go to System > Configuration > Web > Secure and turn on the options "Use secure URLS in frontend" and "Use secure URLS in admin".
Links on your website should now all be https. You can use the following rule to redirect people that bookmarked the http-version of your site:
RewriteCond %{HTTPS} off
RewriteRule ^ https://example.com%{REQUEST_URI} [R,L]
Change the R
flag to R=301
after testing everything works as expected.
The Apache docs recommend against using a rewrite:
To redirect http
URLs to https
, do the following:
<VirtualHost *:80>
ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
# ... SSL configuration goes here
</VirtualHost>
This snippet should go into main server configuration file, not into .htaccess
as asked in the question.
This article might have come up only after the question was asked and answered, but seems to be the current way to go.