0
votes

now I have a website https.

http://www.example.com -> https://www.example.com = OK !

But, I have a problem with www ://example.com -> s://example.com = not good

I would like to have this redirection below : ://example.com -> s://www.example.com

How with RewriteCond and RewriteRule ? Help me plz !

Thanks !

1
I have no idea what your asking. show code if you have it. take with the language if you can and specific library if one is being used. - LhasaDad
RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{SERVER_NAME} =example.com [NC,OR] RewriteCond %{SERVER_NAME} =www.example.com [NC] RewriteRule ^(.*)$ example.com [R=301,L] - Maxence LUCAS
Ok, sorry not abile to help here, not familiar with the apache rewrite rules. sorry. - LhasaDad

1 Answers

1
votes

To enforce https on all requests and redirect to www.example.com

# force https and www
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]

# if already https without www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]