Force removal of WWW in url

/ Published in: Apache
Save to your folder(s)

Using mod_rewrite in Apache to rewrite urls and force removal of www in urls. Good for letting search engine spiders in the right door...

Insert the code in your .htaccess-file in your website's root folder.

Copy this code and paste it in your HTML
  1. # force removal of www IN URL
  2. RewriteEngine On
  3. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  4. RewriteRule ^(.*)$$1 [R=301,L]
  5. # END force removal of www IN URL# force www IN URL


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.