I would like to redirect for 2 situations:
- non-www
- https
I currently use the following in my .htaccess file:
RewriteEngine on #RewriteCond %{HTTP_HOST} ^www\.egps\.org [NC] #RewriteRule ^(.*)$ https://website.org/$1 [L,R=301] RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] I commented out the first 2 lines as they caused a problem. While searching Stackoverflow for answers I found the following accepted answer:
RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^(.*)$ https://www.%1%{REQUEST_URI} [L,R=301,NE] Can someone please explain how I might alter this code to redirect to NON www instead of www?
Can anyone translate into very simple language what these lines of code are actually saying? This is what I gather so far...
- If URL does not have www
- If URL is not preceded by https
- Not sure about this one
- Rewrite URL by adding
HTTPS://www.URL