regexapache.htaccessurlno-www

Trouble removing www from url with https


I want to remove www from URL but,

I am having an issue removing www from url with https (Apache Server).

I have added the following code in .htaccess file, it works, but when I go to http://www.zubizi.com it doesn't work, what I need to do for that????

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ https://zubizi.com/$1 [R=301,L]

Solution

  • Just make the following changes:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.
    RewriteRule ^(.*)$ https://zubizi.com/$1 [R=301,L]
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]