0

I have designed a Online shopping website. Everything works fine with http. Now I want that the profile and the payment gateway should use HTTPS instead of HTTP. I have not dealt with https before and so I am stuck here. Here is my code snippet. I want profile.php to use https. I have seen some post where it has been told to edit mod_rewrite or use some https redirect function. But how will I do that? I am using XAMPP.

    if($rws['user_email']==$UserName && $rws['user_pass']==$UserPwd){
        if($_REQUEST['remember']==1){
            setcookie('uname',$UserName,time()+24*60*60);
            setcookie('pwd',$UserPwd,time()+24*60*60);
        }

        $_SESSION['fname'] = $rws['user_fname'];
        $_SESSION['ud'] = $rws['user_id'];



        header('Location:profile.php');
       }
Kunal Gupta
  • 449
  • 3
  • 22
  • Duplicate of http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite – tyteen4a03 Dec 31 '14 at 08:48
  • Read this post [How to make a website secured with https][1] [1]: http://stackoverflow.com/questions/2205325/how-to-make-a-website-secured-with-https – Jerry Rhule Dec 31 '14 at 08:49

1 Answers1

0

You need to put a rewrite condition in your .htaccess

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
Pixel
  • 1,946
  • 2
  • 15
  • 26
  • I am not familiar with this. Can you please explain how to edit .htaccess? – Subhadeep Kanungo Dec 31 '14 at 09:06
  • You need to redirect every url without the https, create a .htaccess file in the root of the project and past the code. You just need to change the url adress. – Pixel Dec 31 '14 at 09:09