Htaccess Programming Tips & Tricks





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Code Snippets
 List All
 301 Redirect
 404 Redirect
 Htaccess Redirection
 Security
 




Non-WWW to WWW URL - Htaccess

Snippets  Htaccess  Non-WWW to WWW URL
Snippet On
301 Redirect




Code
  
Rate this page :
  [ 0 votes]

.htaccess file is used for webpage redirection. Here is the code snippet to redirect users to access the site without www and vice-versa.

301 Redirect www to non-www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.hscripts.com$ [NC]
RewriteRule ^(.*)$ http://hscripts.com/$1 [L,R=301]


301 Redirect Non www to www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^hscripts.com [NC]
RewriteRule ^(.*)$ http://www.hscripts.com/$1 [R=301,L]




Other Links

web hosting