Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

WWW / No-WWW How to set your website redirection to www or without www by .htaccess?

Chat about web technologies (IIS, Apache, etc...), hosting and server management.
Post Reply
admin
Site Admin
Posts: 45

WWW / No-WWW How to set your website redirection to www or without www by .htaccess?

Post by admin » Thu Aug 22, 2019 3:08 pm

Force the www.

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^your-site.com [NC]
RewriteRule ^(.*)$ http://www.your-site.com/$1 [L,R=301]
Remove the www.

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]

Post Reply