On ruachost.com, you can configure your website to either always include or always remove the www prefix in URLs. This ensures consistency, improves SEO, and prevents duplicate content issues.
Why Control the www Prefix?
-
SEO benefits: Search engines may treat
www.example.comandexample.comas separate sites. -
Brand consistency: Visitors always see the same format.
-
Avoid duplicate content penalties.
-
Better user experience: Redirects visitors to the preferred version automatically.
Adding the www Prefix
To force all visitors to use www.example.com:
-
Open or create the
.htaccessfile in your site’s root directory (public_html). -
Add the following rewrite rules:
## Add www to any URLs that do not have them: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
-
Save the file.
-
Test by visiting
http://example.com— it should redirect tohttp://www.example.com.
Removing the www Prefix
To force all visitors to use example.com without www:
-
Open or create the
.htaccessfile in your site’s root directory. -
Add the following rewrite rules:
## Remove www from any URLs that have them: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\. RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
-
Replace
example.comwith your actual domain name. -
Save the file.
-
Test by visiting
http://www.example.com— it should redirect tohttp://example.com.
Important Notes
-
Use 301 redirects for SEO‑friendly permanent redirection.
-
Only configure one option (add or remove) to avoid redirect loops.
-
If your site uses HTTPS, replace
http://withhttps://in the rules. -
Always back up your
.htaccessfile before editing.