Adding www to a url
From Joomla! Documentation
(Difference between revisions)
(Previous code did not canonicalise www URLs with port number, nor direct IP requests. Use example.com, see RFC 2606.) |
m (categoryadded) |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
== How do I get www as a prefix in all my joomla sites? == | == How do I get www as a prefix in all my joomla sites? == | ||
| − | Add the following to your htaccess file | + | Add the following to your .htaccess file: |
<source lang="Apache"> | <source lang="Apache"> | ||
RewriteEngine On | RewriteEngine On | ||
| Line 8: | Line 8: | ||
</source> | </source> | ||
| − | [[Category:FAQ]] | + | A more complete solution fixing several other canonicalisation issues at the same time: |
| − | [[Category | + | <source lang="Apache"> |
| + | 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] | ||
| + | </source> | ||
| + | |||
| + | <noinclude>[[Category:FAQ]][[Category:Installation]][[Category:Server configurations]]</noinclude> | ||
Latest revision as of 07:12, 19 October 2012
[edit] 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]
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]