.htaccess redirects https:// to https://www.

Hi everyone, quick question,

Is it possible to redirect https://domain.co.uk to https://www.domain.co.uk?

If so how do I do it?

I have no problem redirecting the non secure domains to www. but not sure how to go ahead with the HTTPS. I have googled the problem, but I couldn't find a solution that works.

The current code for the non secure redirect in the .htaccess is

Code:
# SEO URL SettingsRewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk$RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]

...and that all works fine.

Would appreciate any help, I'm sure I am missing something pretty obvious, but I have never had to deal with SSL addresses before.
 
No and I have tried that as https.

I need anything after the https:// to always be prefixed with www.

Sorry I realise I have written "redirects" above, where I should have written "rewrite".
 
Cheers Chris, I have seen both those pages before. The second one doesn't work, and I am not sure where to start with the first one to be honest. I'm not sure which bits to use, as they seem to be for redirecting index.html to a folder.
 
hmm... thats a pain... i'll have another looksee.
 
Yeah tell me about it!

Basically I had to move an ecommerce site, which is running on Opencart, and on the previous host both Welcome-Sedo.co.uk and domain.co.uk worked for http and https.

The new hosts set up a new security certificate, and it only works for www. So if you try and visit https://domain.co.uk you get an untrusted connection warning, but everything works fine for Welcome-Sedo.co.uk, which wouldn't be a problem, except that Google has picked up one or two pages as being https://domain.co.uk

I really appreciate you looking for me, I just can't seem to find the correct solution.
 
stupid SSL certificates... very confusing stuff.. i'll keep looking
 
hmmm thats even more strange that google is picking up a couple of pages without the www. very very strange.

Harry said:
My mate said (at a wild guess) that you might need buy wildcard certificates…

that was one of the things I just looked at too Harry... spooky LOL
 
how about this?

Code:
RewriteEngine onRewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
 
chrismitchell said:
how about this?

Code:
RewriteEngine onRewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

Just tried that it redirects http://domain.com to httpS://www.domain.com.

I've contacted my hosting company support to see if they can help, but I am not holding my breathe, as they have told me before that they can't help with any SSL related problems.


Thanks Harry/Chris...I'll look into the wildcards if the hosting company cannot help.

I don't know why the https has been picked up by Google either...it was for the home page which obviously isn't generally served over a secure connection. The https is only on for the login, account and checkout pages.

On the previous server (which was only used for 3/4 weeks) the whole site was redirected to http://domain as this is how Opencart defaulted, and that worked with the previous certificate, regardless of www. or not. So i'm guessing that is why Google has picked up some pages without the www. prefix, but I still can't see why the home page would have been picked up with https://

If it had been picked up with http:// and no www. the redirects/rewrites would/do work fine.
 
i'm sure that the hosting company will be able to force something for you.
 
Cheers Greg, but that doesn't work either. :(

Oh and I just got this reply from the hosting company:

Thanks for contacting us. You should be able to check for https and then redirect or rewrite to www if this is the case. As we are not a team of developers I do not know the exact code you require but the following documentation should help you get this resolved.

Apache SSL in htaccess examples

I'll have a read...
 
Iain,

Would have suggested above ways so if they have not worked not quite sure.

Just to confirm in head, you are wanting users on the http:// to actually be seeing pages on the https://

Just wondering why a simple redirect to the correct page would not be ok?

Also was in Ayr 2 weekends back great little town! You been to Cactus Jacks? That buckaroo is epic!
 
No I need it to redirect https://domain.com to https://www.domain.com

Also was in Ayr 2 weekends back great little town! You been to Cactus Jacks? That buckaroo is epic!

It has it's moments! First sign of a sunny day and the beach is packed. Was there something on or were you just passing through? Can't say I have been to Cactus Jacks, never really appealed to me.
 
Code:
RewriteEngine onRewriteCond %{HTTPS_HOST} !^www\.RewriteRule ^(.*)$ [URL]http://www.%{HTTPS_HOST}/$1[/URL] [R=301,L]
 
iain_darkflare said:
No I need it to redirect https://domain.com to https://www.domain.com



It has it's moments! First sign of a sunny day and the beach is packed. Was there something on or were you just passing through? Can't say I have been to Cactus Jacks, never really appealed to me.
Ahh ok makes sense now, Not had to do it that way for https://domain to the www. Have had to take the http:// to https:// but thats it so cant be of help!

Yeah was the British Kitesurfing Tour stop. Same weekend as the Races.

We had our evening party there and have to say was god little bar! Great fun with all of us lot with the Buckaroo! Hve you lived in Ayr along time?
 
Back
Top