Redirect WWW to Non WWW with .HTACCESS

[ez-toc]

One of the easiest ways to setup a 301 permanent redirect (your server must be running Apache) from www to non www is by editing the .httaccess.

The .htaccess file is a text file that you add or edit on your site. Basically it adds to or overrides the current server settings. If you have trouble creating a .htaccess file (some text editors won’t create a file named .htaccess) download this example and edit with notepad. You may have to add this code to your current .htaccess or upload it. The .htaccess should be uploaded to the root folder of your web server.

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

How to 301 redirect an old page to a new page?

redirect 301 /old-page.html http://www.yoursite.com/new-page.html

Photography Catagories: