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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Victor KimuraSEO, Web DeveloperAuthor Commented:
By Father's grace, I figured it out. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSL / HTTPS

From novice to tech pro — start learning today.