| non-www redirect doesn't work
|
rhonda427

msg:4335779 | 3:08 pm on Jul 6, 2011 (gmt 0) | I have used [scriptalicious.com...] to generate a code in my .htaccess that will redirect www.mysite.com to mysite.com. But no-matter what I do, this simply doesn't work :(
RewriteEngine On RewriteCond %{HTTP_HOST} ^www.mysite.com [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] It's a Joomla site, and the code directly above the above code is:
## # @version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $ # @package Joomla # @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # @license http://www.gnu.org/copyleft/gpl.html GNU/GPL # Joomla! is Free Software ##
##################################################### # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE # # The line just below this section: 'Options +FollowSymLinks' may cause problems # with some server configurations. It is required for use of mod_rewrite, but may already # be set by your server administrator in a way that dissallows changing it in # your .htaccess file. If using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your sef url's. If they work, # it has been set by your server administrator and you do not need it set here. # #####################################################
## Can be commented out if causes errors, see notes above. Options +FollowSymLinks
# # mod_rewrite in use AddType application/x-httpd-php5 .php Any clues about where to look?
|
g1smd

msg:4336060 | 10:39 pm on Jul 6, 2011 (gmt 0) | The code is not the best way to do it (missing escaping, doesn't redirect all non-canonical requests), but it should have worked for your example. The .htaccess file you are using is years of date. Grab a newer version from Joomla 1.5.23 or later or from Jooomla 1.6.2 or later. There are many changes. The new file also contains a note as to exactly where in the file your redirects should be placed. I would use:
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] The ( ) ? construct prevents HTTP/1.0 requests from triggering an infinite redirect loop. The above code redirects TO www. For redirect in the OTHER direction, remove BOTH occurrences of www from the code.
|
|
|