How do I add or remove www from my domain using .htaccess file?
Now adding or removing "www" is possible when we are using .htaccess file. So if you would like to keep www(www.example.com) or remove www(example.com) from our live url then we should create .htaccess file and add below lines into .htaccess file.
Removing "www" through an .htaccess file
To automatically remove the www from the starting of your domain url, add the following mod_rewrite rule to your .htaccess file. If you don't have that file, create it in a text editor and then upload it to your site root directory:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Adding "www" through an .htaccess file
To automatically add a www to your domain name when there isn't a subdomain, add this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
Popular Posts Hits
How do I add or remove www from my domain using .htaccess file?
Now adding or removing "www" is possible when we are using .htaccess file. So if you would like to keep www(www.example.com) or remove www(example.com) from our live url then we should create .htaccess file and add below lines into .htaccess file.
Removing "www" through an .htaccess file
To automatically remove the www from the starting of your domain url, add the following mod_rewrite rule to your .htaccess file. If you don't have that file, create it in a text editor and then upload it to your site root directory:
Adding "www" through an .htaccess file
To automatically add a www to your domain name when there isn't a subdomain, add this to the htaccess file in your document root:
Already have an account? Login into comment