Monday, June 11, 2012

redirect with WWW htaccess

If you need to redirect your domain name with "WWW" you can use the following htaccess code for Apache based web servers.

Redirect with WWW htaccess

Options +FollowSymLinks
RewriteEngine On

# Mention Domain name

RewriteCond %{HTTP_HOST} ^ [NC]
Rewriterule ^(.*)$$1 [R=301,NC]

# OR
# get domain name automatically.

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

No comments:

Post a Comment