niammuddin

force www or no-www on htaccess

Feb 1st, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #Force www:
  2. RewriteEngine on
  3. RewriteCond %{HTTP_HOST} ^example.com [NC]
  4. RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
  5.  
  6. #Force non-www:
  7. RewriteEngine on
  8. RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
  9. RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Add Comment
Please, Sign In to add comment