How to do a redirect from www to non-www?

I did a redirect with this code in htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} ^$ [NC] RewriteRule ^(.*)$$1 [R=301,L]


Now if I navigate to any page with wwww, then I redirects to and throws 404.

How to make the transition to any page with www were throwing the same without www.
July 2nd 19 at 13:57
1 answer
July 2nd 19 at 13:59
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

You must make sure that in httpd.conf mod_rewrite module is connected and switches on the option FollowSymLinks.

Find more questions by tags Search engine optimizationhtaccess