Difference between revisions of "Adding www to a url"
From Joomla! Documentation
(Marked this version for translation) |
|||
Line 1: | Line 1: | ||
<noinclude><languages /></noinclude> | <noinclude><languages /></noinclude> | ||
<translate> | <translate> | ||
− | == How do I get www as a prefix in all my | + | == How do I get www as a prefix in all my Joomla! sites? == <!--T:1--> |
</translate> | </translate> | ||
<translate><!--T:2--> | <translate><!--T:2--> | ||
− | Add the following to your .htaccess file:</translate> | + | Add the following to your <tt>.htaccess</tt> file:</translate> |
<source lang="Apache"> | <source lang="Apache"> |
Revision as of 09:04, 22 September 2015
How do I get www as a prefix in all my Joomla! sites?[edit]
Add the following to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
A more complete solution fixing several other canonicalisation issues at the same time:
RewriteEngine On
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]