Results 1 to 11 of 11
Thread: Redirect users to https://www
-
12-11-2014, 09:36 PM #1Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
Redirect users to https://www
Hello,
How do I redirect all non https and non-www users to https://www.mydomain.com? I use apache on centos
Thanks so much in advance
Sal
-
12-11-2014, 10:22 PM #2Junior Guru
- Join Date
- May 2013
- Posts
- 183
Using apache you can create a virtual host. I'm not sure if its considered best practice though, but it works.
<VirtualHost *:80>
ServerName domain.com
Redirect permanent / https://www.domain.com
</VirtualHost>
-
12-11-2014, 11:15 PM #3Junior Guru Wannabe
- Join Date
- May 2014
- Posts
- 61
Try putting the code below in a .htaccess file in the document root. Make sure AllowOverride is enabled in the Apache configuration file.
Code:RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
█ █ Phil Kinsley - NotionHosting
█ █ cPanel | SSD | CloudLinux | LiteSpeed | R1Soft Backups and more!
█ █ Shared Hosting | Managed Hosting | Self/Fully Managed VPS | Dedicated Servers | Discounted Domains
-
12-12-2014, 12:19 AM #4Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
Tried
Just tried it but got below issues
domain.com goes to https://domain.com but not https://www.domain.com
https://domain.com shows certificate warning as certificate is only for www.domain.com
-
12-12-2014, 12:21 AM #5Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
-
12-12-2014, 12:23 AM #6~~~~
- Join Date
- May 2008
- Posts
- 3,424
This should get the job done, add it to your .htaccess file:
Code:RewriteEngine On RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Uptime Monitor - Minimize your downtime by being the first to know about it!
Blacklist Monitor - Are any of your IPs or Domains blacklisted? Find out before it gets to affect you or your clients.
-
12-12-2014, 12:25 AM #7Junior Guru Wannabe
- Join Date
- May 2014
- Posts
- 61
█ █ Phil Kinsley - NotionHosting
█ █ cPanel | SSD | CloudLinux | LiteSpeed | R1Soft Backups and more!
█ █ Shared Hosting | Managed Hosting | Self/Fully Managed VPS | Dedicated Servers | Discounted Domains
-
12-12-2014, 12:40 AM #8Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
Did not work
Works fine except it did not move https://domain.com/ to https://www.domain.com/ so i got warning.
Certificate will only work for www version as I have multi domain SSL which only has www.domain.com
-
12-12-2014, 12:48 AM #9Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
-
12-14-2014, 08:18 PM #10Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
I am sorry. this did not work after testing all scenarios. It duplicates the part of url after redirection and does not redirect https://domain.com/ to https://www.domain.com/
I am using multi domain ssl certificate.
-
12-14-2014, 08:21 PM #11Junior Guru Wannabe
- Join Date
- Jul 2014
- Posts
- 42
Similar Threads
-
redirect to HTTPS
By loodwood in forum Hosting Security and TechnologyReplies: 7Last Post: 09-12-2012, 08:28 AM -
.htaccess https redirect different than http redirect
By MTO in forum Hosting Security and TechnologyReplies: 4Last Post: 05-24-2012, 05:14 AM -
http/https www to non-www https redirect
By StealthyHosting in forum Web Design and ContentReplies: 6Last Post: 05-23-2012, 10:26 PM -
Can I redirect to https: ?
By LeMarque in forum Hosting Security and TechnologyReplies: 5Last Post: 10-19-2007, 03:55 PM -
.htaccess redirect all pages to https://www
By LJ Host in forum Hosting Security and TechnologyReplies: 3Last Post: 07-17-2007, 02:42 PM