Home https and www not working properly
Reply: 1

https and www not working properly

Nirav Joshi
1#
Nirav Joshi Published in 2018-02-07 19:35:58Z

As I tried so many things to redirect www to non-www of subdomain via htaccess but not going well

I want to like this

https://test.example.com

but while I write like this

https://www.test.example.com

then the webpage gives me error like this

"Your connection is not private"

i tried this code in htaccess but not working properly

RewriteCond %{HTTP_HOST} ^www\.([^.]+\.example\.com)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

this code only redirects if i didnot mention https in www.test.example.com

Juan
2#
Juan Reply to 2018-02-07 20:20:53Z

To redirect everything to htpps I use the following. It is at the top of the .htaccess.

I have added your two lines for redirecting from www to the domain after the forwarding to https, and changed the HOST_HTTP to HOST_HTTPS.

Please note I haven't tried it.

Perhaps you can remove this if it doesn't apply: RewriteRule ^index\.php$ - [L]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://test.example.com/$1 [R,L]
RewriteCond %{HTTPS_HOST} ^www\.([^.]+\.example\.com)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L]
</IfModule>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.566446 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO