.htaccess rewrite to https and www version

I’m trying to redirect visitors to the https://www version of my site. I have looked at several examples and they all differ. Some use *. which I have been told to avoid. Currently I have the following which works fine on redirecting the non-www version to www but if I uncomment the other rules I get a message that there are too many redirects.

RewriteEngine on
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule .? https://www.domain.eu%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.domain\.eu$
RewriteRule .? https://www.domain.eu%{REQUEST_URI} [R=301,L]
1 Like

Looks like it’s not the directives that are giving me the problem, but the fact I’m using a CDN!

1 Like

ganfalf,

Your commented code is exactly what you need:

[quote=“gandalf458, post:1, topic:234243”]
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .? https://www.domain.eu%{REQUEST_URI} [R=301,L][/quote]

Regards,

DK

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.