Redirect Users to Secure connection

dolan2go
dolan2go used Ask the Experts™
on
Using cPanel, and on a shared server, how can I redirect all users who input http://mysite.com to https://mysite.com?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
Under Domains, click on Redirects

Assuming you want all requests to be redirected to https, click on the Wild Card Redirect checkbox

Author

Commented:
Tintin,

OK, got it. Tried that.  Please view the attached file, which give the following error:

Redirecting to https://flydata.mobi/ will cause a redirection loop because 'http://flydata.mobi/'

    which is located at /home/xxxxxx/public_html/

is above 'https://flydata.mobi/'

    which is located at /home/xxxxxx/public_html/

What am I missing here?
Redirect-cPanel.png
Commented:
Expanding the question: I finally got the code (top) below to work for me while the lower code causes the server to reply with 500.

Are there any suggestions about the security of the top code? My only intent is to have all pages served through port 443.

As a side question, do all sub-directories have to have this code in their .htaccess also, or is there a way to include this redirection for certain sub-directories?
<Works>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

<Causes 500>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) 
https://flydata.mobi/$1 [R]

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial