How to remove or add www from website url with htaccess
do you want to remove www from your domain or your website url .so here is the code that will remove www from your domain name .
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
copy this code and paste this code into your .htacces file and if you cannnot find htaccess file in your root directory or create a new one and paste this code into it.this code will redirect every www request to non www weburl of your website.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
copy this code and paste this code into your .htacces file and if you cannnot find htaccess file in your root directory or create a new one and paste this code into it.this code will redirect every www request to non www weburl of your website.
And if you want to add www to your url then copy this code and paste this code into your htaccess file.this code will add www to your url and redirect all requests to www url.
How to add www to website url with htaccess
RewriteEngine On
| RewriteCond %{HTTP_HOST} ^example.com$ |
| RewriteRule (.*) http://www.example.com$1 [R=301] |
Nice articel, This article help me very well. Thank you. Also please check my article on my site Know All About Htaccess Tutorial. In link article we will learn about Where is my htaccess file.
ReplyDelete