How can I get url rewriting to include www. and not cause an infinite loop problem? I have a problem with url redirection. I need to make sure that the www. is added to the url. I realise that this has to be done in .htaccess and after a bit of research and reading I think the code I need is
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.co.uk [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [R=301,L]
It is a joomla site so the section is then followed by the joomla sef section
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
If I use this firefox warns me:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
IE cant find the page If I remove the re-write lines I get the pages but the url is rewritten to one with no www
How can I force the www. to be in the url?