redirect http to https with .htaccess (Apache)

Hi,

I have a domain:
https://secure.myultratrust.com

When a user arrives at this root sub-domain URL it gets 301 redirected by the index

Open in new window

.php:
<?php
    header( 'Location: https://secure.myultratrust.com/diy/login/login.php' ) ;
?>

Open in new window


What I'm trying to do is if the user types in:
http://secure.myultratrust.com

then it should be a 301 forward to:
https://secure.myultratrust.com/diy/login/login.php

I found this page on stackexchange:
http://stackoverflow.com/questions/4933001/permanent-redirect-from-http-to-https-page

So I tried this but it doesn't work:
RewriteCond %{HTTPS} !ON
RewriteCond ${REQUEST_URI} ^index.php
RewriteRule ^(.*) https://secure.myultratrust.com/diy/login/login.php [R=301, L]

Open in new window


How can I get it to do a 301 redirect to
https://secure.myultratrust.com/diy/login/login.php

when the user goes to the insecure
secure.myultratrust.com
?

Thank you and Father God bless<><,
Victor
Victor KimuraSEO, Web DeveloperAsked:
Who is Participating?
 
Victor KimuraSEO, Web DeveloperAuthor Commented:
I figured this out.

What ended up working is I added an external vhost.conf by adding the lines with in the VirtualHost container for secure.myultratrust.com:80 of the httpd.conf file. My httpd.conf is located at:
/usr/local/apache/conf/httpd.conf (this is Centos 5.6 with WHM 11.4). May be different for you.

You can use: find / -name 'httpd.conf' to find out yours.

Include "/usr/local/apache/conf/userdata/std/2_2/myultrat/*.conf" (this is the default. * = vhost)
Include "/usr/local/apache/conf/userdata/std/2_2/myultrat/secure.myultratrust.com/*.conf" (this overrides the default vhost.conf in the preceding line)

Open in new window

0
 
Victor KimuraSEO, Web DeveloperAuthor Commented:
By Father's grace, I figured it out. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.