0

My site has been hosted on https://example.com

But the problem is when i try to access it with https://www.example.com it still accessible. But i don't want to user to access the site with www instead of it i want to redirect it to https://example.com . How do i make it happen?

Here is the current .htaccess

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
killstreet
  • 1,251
  • 2
  • 15
  • 37
User57
  • 2,453
  • 14
  • 36
  • 72
  • 1
    Possible duplicate of [.htaccess Remove WWW from URL + Directories](https://stackoverflow.com/questions/6515081/htaccess-remove-www-from-url-directories) – Jigs1212 Apr 09 '18 at 10:40

1 Answers1

0
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Kajbo
  • 1,068
  • 3
  • 16
  • 31