301 Server Code


A "301" is a status code that is returned by a website’s server when accessing a URL that has been moved. Just like mail forwarding, a 301 specifies a permanent "change of address" for a page/file which has been moved. A 301 indicates a permanent redirection whereas a 302 indicates a temporary redirection.

Related: 200 Server Code, 302 Server Code, 404 Server Code, 500 Server Code

Examples

Redirect from Non-WWW to WWW


RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.

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

Format: html

Redirect from WWW to Non-WWW


RewriteEngine On RewriteBase /

RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Format: html

Let's Discuss

There are no posts.