To redirect from http:// to http://www. (non www to www)
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
To redirect from http://www. to http:// ,(www to non www)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
To redirect from http:// to http://www. , and also remove the route file (index.php) in the url, put these lines on your htaccess :
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond $1 !^(index\.php|images|css|js|styles|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
About us and this blog
We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.
Request a free quote
We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.
Subscribe to our newsletter!
More from our blog
See all posts Firm Name The name of your business. Logo The PNG image file…
It does not matter what business you pursue but without it’s digital…
Inbound Marketing Inbound Marketing is the process where you engage your website…
Website Importance In Business To have a Website for a business (either small…
What is a Domain Name? What is a Domain Name? The name…
Steps to get your website on google top 10 list : …
Website hacking Website hacking and prevention is a sensitive concept that needs…