Force www or non-www website URL

Post Reply
User avatar
isscbta
Team Member
Posts: 132
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 16 times
Been thanked: 3 times

To force www in your website URL (www.domain.com) at the beginning of your .htaccess file add:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
To force non-www in your website URL (domain.com) at the beginning of your .htaccess file add:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Just change domain.com to your own website domain

Tags:
sennevb
Posts: 11
Joined: Sat Nov 21, 2020 8:32 am

Hello,

I have setup following for my website:

mydomain.com

aliases:
www.mydomain.com
media1.mydomain.com
media2.mydomain.com

i used the mod rewrite to rewrite non www to www, but now the media domains are not reachable anymore..
any workaround for this??
Post Reply