Moved from http to https but include www in urlHow to make https URL to httpURL Rewrite Throws a 301 Redirect When It Shouldn'tRedirecting HTTP to HTTPS?Force api connect HTTP not HTTPSHttp version redirected to https but appeared as 200 OKHTTPS 301 redirecting to http versionHttp to https 301 redirectMagento 1.9.3.8 Full https causes double / ending.htaccess redirect samplesitex.com to samplesitey/alias-page in both https and http variantsRedirect one https url to http
Keeping an "hot eyeball planet" wet
Why is my read in of data taking so long?
TSA asking to see cell phone
Why are there not any MRI machines available in Interstellar?
Why does Mark say he hasn't had a shower for a year and a half?
What is the difference between 1/3, 1/2, and full casters?
Inadvertently nuked my disk permission structure - why?
Replacing tongue and groove floorboards: but can't find a match
Iterate over non-const variables in C++
How do I generate distribution of positive numbers only with min, max and mean?
Why is a dedicated QA team member necessary?
Terence Tao–type books in other fields?
Why are off grid solar setups only 12, 24, 48 VDC?
Which Roman general was killed by his own soldiers for not letting them to loot a newly conquered city?
kids pooling money for Lego League and taxes
Memory capability and powers of 2
Why can't my huge trees be chopped down?
What exactly makes a General Products hull nearly indestructible?
Using "Kollege" as "university friend"?
How important is a good quality camera for good photography?
Grid/table with lots of buttons
Is it better to memorize verb's 1st person perfect tense?
expansion with *.txt in the shell doesn't work if no .txt file exists
Time travel novel: machine makes clones, clones battle to be the one to get back their life
Moved from http to https but include www in url
How to make https URL to httpURL Rewrite Throws a 301 Redirect When It Shouldn'tRedirecting HTTP to HTTPS?Force api connect HTTP not HTTPSHttp version redirected to https but appeared as 200 OKHTTPS 301 redirecting to http versionHttp to https 301 redirectMagento 1.9.3.8 Full https causes double / ending.htaccess redirect samplesitex.com to samplesitey/alias-page in both https and http variantsRedirect one https url to http
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Trying to setup my site so that its on HTTPS AND includes the WWW in the URL.
After a while of searching I found a few posts that helped me redirect to https:
stackoverflow.com/questions/25527671/magento-https-on-all-website-urls-redirect-to-homepage
and then to redirect to get the 'www' added in I used:
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
I ended up with everything working eventually! BUT here is where I think a problem lies. It may be me being niggley BUT when you check a URL now on my site (old redirect URL):
http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
it redirects fine BUT then using a 301 redirect checker:
you can clearly see that there is 2 301 redirects happening here.. I don't think that's ideal..
redirect-checker.org/index.php
Initially this was happening 2-3 3 times SO as an example if I used the URL to check as:
aloe-herbal.co.uk/fitness-weight-management.html
@ www.redirect-checker.org/index.php
it would give me the following:
CONGRATULATION. Everything seems to be fine.
http://aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
http://www.aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
https://www.aloe-herbal.co.uk/fitness-weight-management.html
200 OK
I know it says its okay but I am concerned about the extra trip that its having to make..
So I decided top open a question. Well FIRSTLY thanks for a GREAT related questions feature. WOW gave me a fix straight away:
magento.stackexchange.com/questions/40400/magento-goes-first-the-http-then-redirects-to-https
Works like a charm now there is only 1 301 Moved Permanently listed :)
BUT again if you check: http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
you can see its there 2 times again... That's what I am trying to fix/avoid..
Can any experts help with this last part?
https ce-1.9.1.0 .htaccess 301-redirect
add a comment |
Trying to setup my site so that its on HTTPS AND includes the WWW in the URL.
After a while of searching I found a few posts that helped me redirect to https:
stackoverflow.com/questions/25527671/magento-https-on-all-website-urls-redirect-to-homepage
and then to redirect to get the 'www' added in I used:
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
I ended up with everything working eventually! BUT here is where I think a problem lies. It may be me being niggley BUT when you check a URL now on my site (old redirect URL):
http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
it redirects fine BUT then using a 301 redirect checker:
you can clearly see that there is 2 301 redirects happening here.. I don't think that's ideal..
redirect-checker.org/index.php
Initially this was happening 2-3 3 times SO as an example if I used the URL to check as:
aloe-herbal.co.uk/fitness-weight-management.html
@ www.redirect-checker.org/index.php
it would give me the following:
CONGRATULATION. Everything seems to be fine.
http://aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
http://www.aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
https://www.aloe-herbal.co.uk/fitness-weight-management.html
200 OK
I know it says its okay but I am concerned about the extra trip that its having to make..
So I decided top open a question. Well FIRSTLY thanks for a GREAT related questions feature. WOW gave me a fix straight away:
magento.stackexchange.com/questions/40400/magento-goes-first-the-http-then-redirects-to-https
Works like a charm now there is only 1 301 Moved Permanently listed :)
BUT again if you check: http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
you can see its there 2 times again... That's what I am trying to fix/avoid..
Can any experts help with this last part?
https ce-1.9.1.0 .htaccess 301-redirect
add a comment |
Trying to setup my site so that its on HTTPS AND includes the WWW in the URL.
After a while of searching I found a few posts that helped me redirect to https:
stackoverflow.com/questions/25527671/magento-https-on-all-website-urls-redirect-to-homepage
and then to redirect to get the 'www' added in I used:
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
I ended up with everything working eventually! BUT here is where I think a problem lies. It may be me being niggley BUT when you check a URL now on my site (old redirect URL):
http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
it redirects fine BUT then using a 301 redirect checker:
you can clearly see that there is 2 301 redirects happening here.. I don't think that's ideal..
redirect-checker.org/index.php
Initially this was happening 2-3 3 times SO as an example if I used the URL to check as:
aloe-herbal.co.uk/fitness-weight-management.html
@ www.redirect-checker.org/index.php
it would give me the following:
CONGRATULATION. Everything seems to be fine.
http://aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
http://www.aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
https://www.aloe-herbal.co.uk/fitness-weight-management.html
200 OK
I know it says its okay but I am concerned about the extra trip that its having to make..
So I decided top open a question. Well FIRSTLY thanks for a GREAT related questions feature. WOW gave me a fix straight away:
magento.stackexchange.com/questions/40400/magento-goes-first-the-http-then-redirects-to-https
Works like a charm now there is only 1 301 Moved Permanently listed :)
BUT again if you check: http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
you can see its there 2 times again... That's what I am trying to fix/avoid..
Can any experts help with this last part?
https ce-1.9.1.0 .htaccess 301-redirect
Trying to setup my site so that its on HTTPS AND includes the WWW in the URL.
After a while of searching I found a few posts that helped me redirect to https:
stackoverflow.com/questions/25527671/magento-https-on-all-website-urls-redirect-to-homepage
and then to redirect to get the 'www' added in I used:
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
I ended up with everything working eventually! BUT here is where I think a problem lies. It may be me being niggley BUT when you check a URL now on my site (old redirect URL):
http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
it redirects fine BUT then using a 301 redirect checker:
you can clearly see that there is 2 301 redirects happening here.. I don't think that's ideal..
redirect-checker.org/index.php
Initially this was happening 2-3 3 times SO as an example if I used the URL to check as:
aloe-herbal.co.uk/fitness-weight-management.html
@ www.redirect-checker.org/index.php
it would give me the following:
CONGRATULATION. Everything seems to be fine.
http://aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
http://www.aloe-herbal.co.uk/fitness-weight-management.html
301 Moved Permanently
https://www.aloe-herbal.co.uk/fitness-weight-management.html
200 OK
I know it says its okay but I am concerned about the extra trip that its having to make..
So I decided top open a question. Well FIRSTLY thanks for a GREAT related questions feature. WOW gave me a fix straight away:
magento.stackexchange.com/questions/40400/magento-goes-first-the-http-then-redirects-to-https
Works like a charm now there is only 1 301 Moved Permanently listed :)
BUT again if you check: http://aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/Contact-Us.html
you can see its there 2 times again... That's what I am trying to fix/avoid..
Can any experts help with this last part?
https ce-1.9.1.0 .htaccess 301-redirect
https ce-1.9.1.0 .htaccess 301-redirect
asked Mar 9 '15 at 17:24
UmbrellaUmbrella
84 bronze badges
84 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Did you put
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
before
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
in your .htaccess file?
If so, Apache would rewrite http://aloe-herbal.co.uk to https://aloe-herbal.co.uk and stop processing further rules due to the 'L' flag. Then it would get a new request (https://aloe-herbal.co.uk) which would be rewritten to https://www.aloe-herbal.co.uk, hence double redirect. Try putting the 'www.'-adding bit before the HTTPS part.
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
add a comment |
First, make sure that the unsecure as well as secure base URL under System - Configuration - Web is configured to use https
. Then try this in your .htaccess
:
############################################
## enables the usage of %ENV:proto as the protocol (http vs https) in the rewrite rules
RewriteCond %HTTPS =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %HTTPS !=on
RewriteRule ^(.*)$ - [env=proto:http]
############################################
## redirect from non-www to www
RewriteCond %HTTP_HOST !^www. [NC]
RewriteRule ^ %ENV:proto://www.%HTTP_HOST%REQUEST_URI [R=301,L]
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
add a comment |
Forget about all this htaccess rewrite.
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.
EDITED cause mobile screwed up the answer.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f60170%2fmoved-from-http-to-https-but-include-www-in-url%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Did you put
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
before
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
in your .htaccess file?
If so, Apache would rewrite http://aloe-herbal.co.uk to https://aloe-herbal.co.uk and stop processing further rules due to the 'L' flag. Then it would get a new request (https://aloe-herbal.co.uk) which would be rewritten to https://www.aloe-herbal.co.uk, hence double redirect. Try putting the 'www.'-adding bit before the HTTPS part.
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
add a comment |
Did you put
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
before
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
in your .htaccess file?
If so, Apache would rewrite http://aloe-herbal.co.uk to https://aloe-herbal.co.uk and stop processing further rules due to the 'L' flag. Then it would get a new request (https://aloe-herbal.co.uk) which would be rewritten to https://www.aloe-herbal.co.uk, hence double redirect. Try putting the 'www.'-adding bit before the HTTPS part.
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
add a comment |
Did you put
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
before
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
in your .htaccess file?
If so, Apache would rewrite http://aloe-herbal.co.uk to https://aloe-herbal.co.uk and stop processing further rules due to the 'L' flag. Then it would get a new request (https://aloe-herbal.co.uk) which would be rewritten to https://www.aloe-herbal.co.uk, hence double redirect. Try putting the 'www.'-adding bit before the HTTPS part.
Did you put
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
before
RewriteCond %HTTP_HOST !^www.
RewriteRule ^(.*)$ https://www.%HTTP_HOST%REQUEST_URI [L,R=301]
in your .htaccess file?
If so, Apache would rewrite http://aloe-herbal.co.uk to https://aloe-herbal.co.uk and stop processing further rules due to the 'L' flag. Then it would get a new request (https://aloe-herbal.co.uk) which would be rewritten to https://www.aloe-herbal.co.uk, hence double redirect. Try putting the 'www.'-adding bit before the HTTPS part.
answered Mar 9 '15 at 20:26
Maciek LewkowiczMaciek Lewkowicz
1981 silver badge10 bronze badges
1981 silver badge10 bronze badges
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
add a comment |
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
hello @maciek YES i did put the www part before the https.. I tested it many ways including the way you have stated NOT to do it.. but adding the rules as you have suggested and as I have implemented doesnt seem to work.
– Umbrella
Mar 11 '15 at 12:15
add a comment |
First, make sure that the unsecure as well as secure base URL under System - Configuration - Web is configured to use https
. Then try this in your .htaccess
:
############################################
## enables the usage of %ENV:proto as the protocol (http vs https) in the rewrite rules
RewriteCond %HTTPS =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %HTTPS !=on
RewriteRule ^(.*)$ - [env=proto:http]
############################################
## redirect from non-www to www
RewriteCond %HTTP_HOST !^www. [NC]
RewriteRule ^ %ENV:proto://www.%HTTP_HOST%REQUEST_URI [R=301,L]
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
add a comment |
First, make sure that the unsecure as well as secure base URL under System - Configuration - Web is configured to use https
. Then try this in your .htaccess
:
############################################
## enables the usage of %ENV:proto as the protocol (http vs https) in the rewrite rules
RewriteCond %HTTPS =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %HTTPS !=on
RewriteRule ^(.*)$ - [env=proto:http]
############################################
## redirect from non-www to www
RewriteCond %HTTP_HOST !^www. [NC]
RewriteRule ^ %ENV:proto://www.%HTTP_HOST%REQUEST_URI [R=301,L]
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
add a comment |
First, make sure that the unsecure as well as secure base URL under System - Configuration - Web is configured to use https
. Then try this in your .htaccess
:
############################################
## enables the usage of %ENV:proto as the protocol (http vs https) in the rewrite rules
RewriteCond %HTTPS =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %HTTPS !=on
RewriteRule ^(.*)$ - [env=proto:http]
############################################
## redirect from non-www to www
RewriteCond %HTTP_HOST !^www. [NC]
RewriteRule ^ %ENV:proto://www.%HTTP_HOST%REQUEST_URI [R=301,L]
First, make sure that the unsecure as well as secure base URL under System - Configuration - Web is configured to use https
. Then try this in your .htaccess
:
############################################
## enables the usage of %ENV:proto as the protocol (http vs https) in the rewrite rules
RewriteCond %HTTPS =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %HTTPS !=on
RewriteRule ^(.*)$ - [env=proto:http]
############################################
## redirect from non-www to www
RewriteCond %HTTP_HOST !^www. [NC]
RewriteRule ^ %ENV:proto://www.%HTTP_HOST%REQUEST_URI [R=301,L]
answered Mar 10 '15 at 11:58
SimonSimon
4,6881 gold badge21 silver badges61 bronze badges
4,6881 gold badge21 silver badges61 bronze badges
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
add a comment |
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
hello simon, to confirm I have used HTTPS in both unsecure AND secure URL in magento configuration. Also re: htaccess rules, that's contradicting with the advice given by @maciek and doesn't work with my setup. It either breaks OR has multiple redirects.
– Umbrella
Mar 11 '15 at 12:17
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
@Umbrella the htaccess rules I posted above are only doing one redirect. Did you try them?
– Simon
Mar 11 '15 at 12:53
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
yes i did. although it works its NOT ideal as the code you provided has multiple redirects AND has a 302 thrown into it: aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 302 Found aloe-herbal.co.uk/categories/Bee-Hive-Products/pages/… 301 Moved Permanently aloe-herbal.co.uk/customer-service 200 OK where as the code I am using only has the 2 and NO 302 involved. pls chck @ redirect-checker.org/index.php with lst URL gven 1st post
– Umbrella
Mar 11 '15 at 13:23
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
the code I am currently using is: # Rewrite any request to the wrong domain to use www. RewriteCond %HTTP_HOST !^www. RewriteRule ^(.*)$ %HTTP_HOST%REQUEST_URI [L,R=301] # Rewrite to HTTPS: RewriteCond %HTTPS off # Don't put www. here. If it is already there it will be included, if not # the ABOVE rule will catch it. RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] DOES the job apart from the 2 redirects involved for the URL's referenced in first post...
– Umbrella
Mar 11 '15 at 13:27
add a comment |
Forget about all this htaccess rewrite.
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.
EDITED cause mobile screwed up the answer.
add a comment |
Forget about all this htaccess rewrite.
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.
EDITED cause mobile screwed up the answer.
add a comment |
Forget about all this htaccess rewrite.
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.
EDITED cause mobile screwed up the answer.
Forget about all this htaccess rewrite.
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.
EDITED cause mobile screwed up the answer.
answered Mar 4 '16 at 19:47
MichaelMichael
5051 gold badge4 silver badges13 bronze badges
5051 gold badge4 silver badges13 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f60170%2fmoved-from-http-to-https-but-include-www-in-url%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown