Abdelqader Blog

Abdelqader Blog

Add or remove (www) from URL

sometimes you wanted push users to access you website with using (www) sub-domain or without, especially if you are using that for consistency, as well as SEO’s, so to handle this issue, this is what you have to do.

in this case i am talking to apache users, you could add the below code to .htaccess file to force the (www).

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

for removing the (www).

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

Post a comment