0

I've added the non www url into my gerenal - setting - WordPress Address (URL) & Site Address (URL)

and edited my wordpress .htaccess as below. but it still doesn't redirect to the non www site, any idea why?

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

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

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
Shaho
  • 157
  • 3
  • 15

1 Answers1

1

You can use below rewrite rule i.e

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

If you don't want to use Mod rewrite rule then use redirect i.e

<VirtualHost 127.0.0.1:80>
        ServerName www.example.com
        Redirect permanent / http://example.com/
</VirtualHost>
Pandurang
  • 1,656
  • 2
  • 6
  • 10