WWW or No WWW

Section 13 is where we can decide whether to use www. or no www. as part of the domain name.

www.

To make the site use "www." in the domain, uncomment block 13A:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

no www.

To make the site not have a "www." subdomain and use a "naked" domain instead, uncomment block 13B:

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]

Further Reading

ProcessWire aside, there are some pros and cons with each approach. We recommend reading the sources of this episode for a further discussion on the topic.


Previous Next

Episode #
4 of 7
Course
.htaccess File

ProCache: v405 Render date: 2025-12-06 04:57:54 Page render time: 0.0761s Total w/ProCache: 0.0765s