Actions

Difference between revisions of "Adding www to a url"

From Joomla! Documentation

(Previous code did not canonicalise www URLs with port number, nor direct IP requests. Use example.com, see RFC 2606.)
Line 2: Line 2:
  
 
Add the following to your htaccess file
 
Add the following to your htaccess file
<source lang="text">
+
<source lang="Apache">
 
RewriteEngine On
 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.net$ [NC]
+
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.domain.net/$1 [R=301,L]
+
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
 
</source>
 
</source>
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]
 
[[Category::Installation]]
 
[[Category::Installation]]

Revision as of 12:36, 7 March 2011

How do I get www as a prefix in all my joomla sites?

Add the following to your htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

[[Category::Installation]]