5 Replies - 1269 Views - Last Post: 31 January 2012 - 09:14 AM Rate Topic: -----

#1 JohnPringle   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 37
  • Joined: 13-January 12

How can I redirect users to https from http

Posted 31 January 2012 - 04:06 AM

hello,

I am having trouble redirecting my users to the https version of my site.
I have been through many forums and not found any answer that works.

I am including the following php at the top of every page:
<?php
	if($_SERVER['SERVER_PORT']!=80)
	{
		$redirect= "https://www.pringlepoker.com".$_SERVER['PHP_SELF'];
		header("Location: ".$redirect);
                exit();
	}
?>


but all I get is the http version of the site

I have also tried using a .htaccess file to redirect using this code:
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.pringlepoker.com/$1 [R,L]


but I just get a redirect loop error
and this is the solution every forum has and people are responding saying it works,
but it doesn't work for me :(

I contacted support for my host and they said:

Dear John,

Thank you for contacting 123-reg on the 26th January 2012.

I can confirm that your SSL was not pointing to the correct virtual IP address, I have corrected this for you now. Your SSL should be working within the next 24 hours time. I apologise for any inconvenience this may have caused you.

If we can be of any further help with regard to this or any other matter, please do not hesitate to contact us.

Kind regards,

Darshan

That was 4 days ago, I sent them another message saying it's still not working and they haven't responded.
I believe it's something that I need to do but I can't find the answer.

Can any of you help me?

Thanks in advance,

John

Is This A Good Question/Topic? 0
  • +

Replies To: How can I redirect users to https from http

#2 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6875
  • View blog
  • Posts: 31,665
  • Joined: 10-May 07

Re: How can I redirect users to https from http

Posted 31 January 2012 - 04:26 AM

Can you successfully load the https version of your site? I would verify this before trying to write a script.
Was This Post Helpful? 0
  • +
  • -

#3 JohnPringle   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 37
  • Joined: 13-January 12

Re: How can I redirect users to https from http

Posted 31 January 2012 - 05:09 AM

Yes I can and here is the link to it,

Pringle Poker

thanks :)
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: How can I redirect users to https from http

Posted 31 January 2012 - 05:53 AM

Why are you checking to see if the port ISN'T 80? https runs on port 443 (usually).
Was This Post Helpful? 0
  • +
  • -

#5 JohnPringle   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 37
  • Joined: 13-January 12

Re: How can I redirect users to https from http

Posted 31 January 2012 - 06:18 AM

View PostJackOfAllTrades, on 31 January 2012 - 05:53 AM, said:

Why are you checking to see if the port ISN'T 80? https runs on port 443 (usually).


I did spot that but i had tried a few different ones and just posted the wrong one by mistake. I tried if($port != 443) and if($port == 80) which I know are correct and should work but I still only get the http version.

I have also tried another .htaccess method:
SSLRequireSSL
#no non-ssl access
Redirect permanent https://www.pringlepoker.com/


but this just gives me an internal server error :(

This post has been edited by JohnPringle: 31 January 2012 - 06:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 codeprada   User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 963
  • View blog
  • Posts: 2,382
  • Joined: 15-February 11

Re: How can I redirect users to https from http

Posted 31 January 2012 - 09:14 AM

I think you should use the htaccess file for this. Instead of using the server port you could test for https at the beginning of the HTTP_HOST. I believe you were just missing the flag at the end of the RewriteRule [R=301,L]

Here's an example
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^https://.*$ [NC]
RewriteRule ^(.*)$ https://YOURDOMAINHERE/$1 [R=301,L]



Using the server port...
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 [NC]
RewriteRule ^(.*)$ https://YOURDOMAINHERE/$1 [R=301,L]



Also have a look at this link. Htaccess Rewrites – Rewrite Tricks and Tips

This post has been edited by codeprada: 31 January 2012 - 09:15 AM
Reason for edit:: Additional resources

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1