Following rewrite rule will add www to all URL's on your website in case a visitor didn't type www or followed a link without www. Add this to your .htaccess file:


Options +FollowSymLinks
RewriteEngine On
rewritecond %{HTTP_HOST} ^yourdomain.com$ [nc]
rewriterule ^(.*)$ http://www.yourdomain.com/$1 [l,r=301,nc]

 

 

Syntax:

rewritecond - defines rewrite condition
%{HTTP_HOST}  - Server variable
^ - start matching
$ - end matching
[nc] - non case sensitive
rewriterule - defines rewrite rule
(.*) - match everything
$1 - append original URL part captured in (.*)
l - last rule (only omit in linked rules)
r=301 - redirect using 301 response (permanent redirect)

No comments

Leave your comment

In reply to Some User
Captcha Image