O'Niel O'Niel -4 years ago 156
HTTP Question

Redirect HTTP to HTTPS

I currently use this code to redirect HTTP to HTTPS:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

It's working, http://website.com gets redirected to https://website.com,
however when I'm not on the website and try to go https://website.com/about or https://website.com/contact I get redirected to https://website.com/index.php

I can only visit /pages when I'm already on the website.
How to fix this?
I tried several .htaccess scripts but none worked.

Try to click http://ndvibes.com/about you'll get redirected to index.php if you're not already on the website.
How to fix? Thanks!

Answer Source

This should work better.

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://website.com/$1 [R=301,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download