How to redirect the non-www address to the www
Moderator: General Support Moderators
-
- Joomla! Intern
- Posts: 63
- Joined: Tue Jul 17, 2007 8:13 pm
- Contact:
How to redirect the non-www address to the www
Hi, I'm sure this has been discussed a million times here, but I've followed some suggestions on different threads and I believe due to the passage of time, there may be a better option now days. My question is, what's my best option to redirect the non-www pages to the www, I beleive this referred to as canonicalization. In joomla 1.0, I didn't have this issue, or maybe sh404sef took care of this, but I tried adding to the .htaccess file and its not working for me. Is there an easy fix, like a sef-url component or plugin, or can someone give me the proper .htaccess code.
thanks in advance
thanks in advance
- dhuelsmann
- Joomla! Master
- Posts: 19659
- Joined: Sun Oct 02, 2005 12:50 am
- Location: Omaha, NE
- Contact:
Re: How to redirect the non-www address to the www
Try this code in your .htaccess changing it to fit your situation
Code: Select all
########## Begin - Redirecting non-www request to www
#
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]
#
########## End - Redirecting non-www request to www
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
-
- Joomla! Intern
- Posts: 63
- Joined: Tue Jul 17, 2007 8:13 pm
- Contact:
Re: How to redirect the non-www address to the www
Thank you dhuelsmann, i tried adding that code, but didn't work. Does it need to be placed in a particluar area, or need to replace anything?
thanks
thanks
- aaron_nimocks
- Joomla! Fledgling
- Posts: 4
- Joined: Sat Jan 03, 2009 9:17 pm
Re: How to redirect the non-www address to the www
Not to insult you but that code looks like it should work. Did you change the mysite to your sites name in both spots?
-
- Joomla! Intern
- Posts: 63
- Joined: Tue Jul 17, 2007 8:13 pm
- Contact:
Re: How to redirect the non-www address to the www
yes, i added the sites name in both positions and paced the code after "end joomla core sef" section. Was wondering if it went somewhere in particular or in place of some particular code.
- dhuelsmann
- Joomla! Master
- Posts: 19659
- Joined: Sun Oct 02, 2005 12:50 am
- Location: Omaha, NE
- Contact:
Re: How to redirect the non-www address to the www
Place it immediately after
But you may also want to check whether your rewrite is working -
Let's test to see if mod_rewrite is enabled on your server. Place only the following code in .htaccess:
Now point your browser to: http://www.yoursite.com/google.html
If it redirects you to Google - mod_rewrite is working.
If it gives you an error - mod_rewrite is not working.
Note: Replace "www.yoursite.com" with your actual web site domain.
Code: Select all
RewriteEngine On
Let's test to see if mod_rewrite is enabled on your server. Place only the following code in .htaccess:
Code: Select all
RewriteEngine On
Options +FollowSymLinks
Redirect /google.html http://www.google.com
If it redirects you to Google - mod_rewrite is working.
If it gives you an error - mod_rewrite is not working.
Note: Replace "www.yoursite.com" with your actual web site domain.
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
-
- Joomla! Intern
- Posts: 63
- Joined: Tue Jul 17, 2007 8:13 pm
- Contact:
Re: How to redirect the non-www address to the www
Thank you, it finally worked. The problem must have been in the placement of the code. As I had it at the end of the htaccess.
Thank you again for your time and patience.
Thank you again for your time and patience.
- roma64
- Joomla! Enthusiast
- Posts: 110
- Joined: Mon Feb 12, 2007 12:18 pm
- Location: Reading, PA
- Contact:
Re: How to redirect the non-www address to the www
First of all, I was not sure whether to select 'Post a Reply' or 'New Post' button for this redirecting from non-www to http://www.domain topic and I sincerely do apologize if I messed up.
this problem has been bugging me for some times now and a resolution would really let me sleep (LOL). I have Joomla 1.5.9 and my Core Joomla SEO Settings are as follow:
Search Engine Friendly URLs= Yes
Use Apache mod_rewrite = Yes ( tested it with the Redirect /google.html http://www.google.com and it took me to google after typing my domain.com/google.html)
I am not using any other SEO except the core Joomla one.
I read most of the forum regarding the topic of redirecting from non-www to http://www.domain with various changes to the RewriteCond and RewriteRule but with no luck. I am having problem with Google Webmaster Tool where it reports that my site's sitemap has the following warning:
All the URLs in your Sitemap are marked as having dynamic content.
All the URLs in your Sitemap are marked as having dynamic content (the value of is "always"). Because dynamic content is difficult for search engines to crawl and index, this may impact your site's performance in search results. Check your Sitemap to make sure your site information is correct.
my htaccess is as follow (I removed the real domain for I am not sure whether I should included or not for security reasons - My site has been hacked once before and I am trying to avoid that from happening again):
==================Start of htaccess======================
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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.
#
#####################################################
# 1and1 hosting fix
# If you are intending to use php 5 by default (recommended) then add the line below
AddType x-mapp-php5 .php
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
#
# mod_rewrite in use
RewriteEngine On
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.html
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
=================End of htaccess
As you can see from the first 4 lines from where the #End - Joomla! core SEF Section# starts above, I am also trying to setup a custom 404 error page (that should take visitors to a custom 404 error page with navigational menu but it is not working. I can only ask for 1 resolution at a time (both would be better though...LOL). Again, I am battling a war with Google Webmaster Tool regarding the Sitemap warning and I hate having errors or warnings regarding my site, therefore, your assistance with the above "redirecting from non-www to http://www.domain" issue would be greatly appreciated. Thanks a million.
Sincerely yours!
Roma64
this problem has been bugging me for some times now and a resolution would really let me sleep (LOL). I have Joomla 1.5.9 and my Core Joomla SEO Settings are as follow:
Search Engine Friendly URLs= Yes
Use Apache mod_rewrite = Yes ( tested it with the Redirect /google.html http://www.google.com and it took me to google after typing my domain.com/google.html)
I am not using any other SEO except the core Joomla one.
I read most of the forum regarding the topic of redirecting from non-www to http://www.domain with various changes to the RewriteCond and RewriteRule but with no luck. I am having problem with Google Webmaster Tool where it reports that my site's sitemap has the following warning:
All the URLs in your Sitemap are marked as having dynamic content.
All the URLs in your Sitemap are marked as having dynamic content (the value of is "always"). Because dynamic content is difficult for search engines to crawl and index, this may impact your site's performance in search results. Check your Sitemap to make sure your site information is correct.
my htaccess is as follow (I removed the real domain for I am not sure whether I should included or not for security reasons - My site has been hacked once before and I am trying to avoid that from happening again):
==================Start of htaccess======================
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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.
#
#####################################################
# 1and1 hosting fix
# If you are intending to use php 5 by default (recommended) then add the line below
AddType x-mapp-php5 .php
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
#
# mod_rewrite in use
RewriteEngine On
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.html
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
=================End of htaccess
As you can see from the first 4 lines from where the #End - Joomla! core SEF Section# starts above, I am also trying to setup a custom 404 error page (that should take visitors to a custom 404 error page with navigational menu but it is not working. I can only ask for 1 resolution at a time (both would be better though...LOL). Again, I am battling a war with Google Webmaster Tool regarding the Sitemap warning and I hate having errors or warnings regarding my site, therefore, your assistance with the above "redirecting from non-www to http://www.domain" issue would be greatly appreciated. Thanks a million.
Sincerely yours!
Roma64
SimplerWebs
- dhuelsmann
- Joomla! Master
- Posts: 19659
- Joined: Sun Oct 02, 2005 12:50 am
- Location: Omaha, NE
- Contact:
Re: How to redirect the non-www address to the www
Your www redirection will not work because you placed it at the end of all other rewrites. Place it immediately after
Code: Select all
RewriteEngine On
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org
- roma64
- Joomla! Enthusiast
- Posts: 110
- Joined: Mon Feb 12, 2007 12:18 pm
- Location: Reading, PA
- Contact:
Re: How to redirect the non-www address to the www
dhuelsmann! Thank you for your assistance and quick response. I did make the changes and it worked but now, when I click on any menu, I get the following error:
Bad Request - Your browser sent a request that this server could not understand.
I have not made any changes to my menus and maybe once I do that, the above error might go away. Once again, dhuelsmann, thank you for your quick response and assistance.
Sincerely yours!
Roma
Bad Request - Your browser sent a request that this server could not understand.
I have not made any changes to my menus and maybe once I do that, the above error might go away. Once again, dhuelsmann, thank you for your quick response and assistance.
Sincerely yours!
Roma
SimplerWebs
-
- Joomla! Apprentice
- Posts: 36
- Joined: Thu Jan 10, 2008 9:25 pm
- Contact:
Re: How to redirect the non-www address to the www
Hi, I'm trying to do this on my site, but I can't figure out why it isn't working. I'm posting my htaccess file below. I've tried numerous variations of what you said to do, but it's still not working.
Code: Select all
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
########## Begin - Redirecting non-www request to www
#
RewriteEngine On
RewriteCond %{HTTP_HOST} ^airplaneconnection.com [NC]
RewriteRule (.*) http://www.airplaneconnection.com/$1 [L,R=301]
#
########## End - Redirecting non-www request to www
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
Skavyx Aviation - http://www.skavyx.com
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
- roma64
- Joomla! Enthusiast
- Posts: 110
- Joined: Mon Feb 12, 2007 12:18 pm
- Location: Reading, PA
- Contact:
Re: How to redirect the non-www address to the www
bkmjet!
Thanks to dhuelsmann, I have my redirection working perfectly. Try the following .htaccess code:
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^airplaneconnection.com [NC]
RewriteRule (.*) http://www.airplaneconnection.com/$1 [L,R=301]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
I know you used the ########## Begin - Redirecting non-www request to www and ########## End - Redirecting non-www request to www lines , therefore, you can use the following rewrite code (right after the #mod_rewrite in use line):
RewriteEngine On
########## Begin - Redirecting non-www request to www
RewriteCond %{HTTP_HOST} ^airplaneconnection.com [NC]
RewriteRule (.*) http://www.airplaneconnection.com/$1 [L,R=301]
########## End - Redirecting non-www request to www
I hope this helps!
With Regards!!!
Roma64
Thanks to dhuelsmann, I have my redirection working perfectly. Try the following .htaccess code:
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^airplaneconnection.com [NC]
RewriteRule (.*) http://www.airplaneconnection.com/$1 [L,R=301]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
I know you used the ########## Begin - Redirecting non-www request to www and ########## End - Redirecting non-www request to www lines , therefore, you can use the following rewrite code (right after the #mod_rewrite in use line):
RewriteEngine On
########## Begin - Redirecting non-www request to www
RewriteCond %{HTTP_HOST} ^airplaneconnection.com [NC]
RewriteRule (.*) http://www.airplaneconnection.com/$1 [L,R=301]
########## End - Redirecting non-www request to www
I hope this helps!
With Regards!!!
Roma64
SimplerWebs
-
- Joomla! Apprentice
- Posts: 36
- Joined: Thu Jan 10, 2008 9:25 pm
- Contact:
Re: How to redirect the non-www address to the www
Alright, I now it's been a while, but that suggestion didn't work, so I'm still looking for an answer if anybody has one
Skavyx Aviation - http://www.skavyx.com
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
-
- Joomla! Apprentice
- Posts: 33
- Joined: Wed Apr 15, 2009 7:42 am
- Contact:
Re: How to redirect the non-www address to the www
If a web site is accessible under both http://www.example.com and example.com domains, you should be a responsible webmaster and remove the ambiguity altogether, through the following rewrite rules:
That should solve the problem
Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
-
- Joomla! Apprentice
- Posts: 36
- Joined: Thu Jan 10, 2008 9:25 pm
- Contact:
Re: How to redirect the non-www address to the www
thanks, it works now
Skavyx Aviation - http://www.skavyx.com
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
Signature rules: Literal URLs only - http://forum.joomla.org/viewtopic.php?f=8&t=65
-
- Joomla! Apprentice
- Posts: 6
- Joined: Sun Apr 12, 2009 8:32 pm
Re: How to redirect the non-www address to the www
sory for re post but as i use above tutor for 301
above in the box is my problem as i am insert the htacces bellow:
RewriteEngine On
########## Begin - Redirecting non-www request to www
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule (.*) http://www.mydomain.com/$1 [L,R=301]
########## End - Redirecting non-www request to www
Code: Select all
I use Com SEF Servicemap and which generates a sitemap for the site. This produces an xml file for Google which I have submitted.
I have received warnings:
"URLs not followed
When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL"
Before submit sitemap to google I use some trick to add www. <--- in htaccess such as I read the trick in this forum. but the urls sitemap that issued by sef servicemap in my site all resulted by non www. but urls that given warning by google run correctly.
so any body can help me to solve this problem?
Thank in advance :D
RewriteEngine On
########## Begin - Redirecting non-www request to www
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule (.*) http://www.mydomain.com/$1 [L,R=301]
########## End - Redirecting non-www request to www
-
- Joomla! Intern
- Posts: 72
- Joined: Tue Apr 14, 2009 5:48 am
Re: How to redirect the non-www address to the www
I tried this too and it works ok for me, thanks for this
Yahoo Web Hosting for Joomla http://thehostpimp.com/yahoo.htm
-
- Joomla! Apprentice
- Posts: 14
- Joined: Fri Apr 24, 2009 4:36 am
Re: How to redirect the non-www address to the www
Thanks, I was looking for that.dhuelsmann wrote:Your www redirection will not work because you placed it at the end of all other rewrites. Place it immediately afterCode: Select all
RewriteEngine On
-
- Joomla! Apprentice
- Posts: 14
- Joined: Fri Apr 24, 2009 4:36 am
Re: How to redirect the non-www address to the www
dhuelsmann wrote:Try this code in your .htaccess changing it to fit your situationCode: Select all
########## Begin - Redirecting non-www request to www # RewriteEngine On RewriteCond %{HTTP_HOST} ^mysite.com [NC] RewriteRule (.*) http://www.mysite.com/$1 [L,R=301] # ########## End - Redirecting non-www request to www
Thanks a million
-
- Joomla! Fledgling
- Posts: 2
- Joined: Thu Jul 30, 2009 12:46 pm
I still Have this issue ive tried everything
I Have read this complete thread but still when I go to http://phelans.co.uk it errors.
This is my .htaccess file:
Can anyone see any issues with the redirect code??
Thank you,
This is my .htaccess file:
Code: Select all
##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^phelans.co.uk [NC]
RewriteRule (.*) http://www.phelans.co.uk/$1 [L,R=301]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
Thank you,
-
- Joomla! Apprentice
- Posts: 25
- Joined: Fri Jul 04, 2008 1:51 am
Re: How to redirect the non-www address to the www
Don't mean to scratch up this old thread but my issue is that I want to redirect my www to the non-www version of the site. Here is my htaccess....what did I do wrong here? Thanks in advance.
##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^indiaredd.com [NC]
RewriteRule (.*) http://indiaredd.com/$1 [L,R=301]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^indiaredd.com [NC]
RewriteRule (.*) http://indiaredd.com/$1 [L,R=301]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
- rajeshatbuzz
- Joomla! Enthusiast
- Posts: 198
- Joined: Wed Sep 24, 2008 6:06 pm
- Location: Bangalore
- Contact:
Re: How to redirect the non-www address to the www
I used above given explanation but not make it work. Plz find my .htacces.
where i changed the domain name to my domain name...
where i changed the domain name to my domain name...
Code: Select all
##
# @version $Id: htaccess.txt 9975 2008-01-30 17:02:11Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sakkathhot.com [NC]
RewriteRule (.*) http://www.sakkathhot.com/$1 [L,R=301]
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
cmsGalaxy Team, Web Developer, Bangalore, India
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
- rajeshatbuzz
- Joomla! Enthusiast
- Posts: 198
- Joined: Wed Sep 24, 2008 6:06 pm
- Location: Bangalore
- Contact:
Re: How to redirect the non-www address to the www
Hi Tried following code as well but error is coming like Redirect Loop...
Please help me out.
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sakkathhot.com [NC]
RewriteRule ^(.*)$ http://www.sakkathhot.com/$1 [L,R=301]
</IfModule>
cmsGalaxy Team, Web Developer, Bangalore, India
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
- rajeshatbuzz
- Joomla! Enthusiast
- Posts: 198
- Joined: Wed Sep 24, 2008 6:06 pm
- Location: Bangalore
- Contact:
Re: How to redirect the non-www address to the www
Hi, I have tried following workaround to check whether mod rewrite is working or not and found that its working.
One important thing which i want to mentioned here is, My site is set subdirectories instead of root.
please suggest as i m getting confused what to do
Code: Select all
writeEngine On
Options +FollowSymLinks
Redirect /google.html http://www.google.com
please suggest as i m getting confused what to do
cmsGalaxy Team, Web Developer, Bangalore, India
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
- rajeshatbuzz
- Joomla! Enthusiast
- Posts: 198
- Joined: Wed Sep 24, 2008 6:06 pm
- Location: Bangalore
- Contact:
Re: How to redirect the non-www address to the www
After having R & D long, i could find following inputs.
1 . After applying all above code in .htacces && sh404sef disable - its working
2. If sh404sef is enable && "301 redirect from JOOMLA SEF to sh404SEF" is set yes - its not working
3. if sh404sef is enable && "301 redirect from JOOMLA SEF to sh404SEF" is set No - site is coming up but its pages are having 404 isses and domain name is getting added in url.
Any idea if we apply above mentioned code in .htaccess, what is the best suitable setting for sh404sef? my site link is www.sakkathhot.com
1 . After applying all above code in .htacces && sh404sef disable - its working
2. If sh404sef is enable && "301 redirect from JOOMLA SEF to sh404SEF" is set yes - its not working
3. if sh404sef is enable && "301 redirect from JOOMLA SEF to sh404SEF" is set No - site is coming up but its pages are having 404 isses and domain name is getting added in url.
Any idea if we apply above mentioned code in .htaccess, what is the best suitable setting for sh404sef? my site link is www.sakkathhot.com
cmsGalaxy Team, Web Developer, Bangalore, India
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
Website Design - Development - SEO - Joomla
www.cmsGalaxy.com
- Pylon
- Joomla! Enthusiast
- Posts: 150
- Joined: Tue Aug 28, 2007 3:29 pm
- Location: London, UK
- Contact:
Re: How to redirect the non-www address to the www
Although it's good to know what you can do with .htaccess and how to do it, you can address your www/non-www issues with this extension http://extensions.joomla.org/extensions ... adata/5355
http://www.pylondesign.co.uk We don't design Pylons...
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
- v2interactive
- Joomla! Guru
- Posts: 823
- Joined: Thu May 28, 2009 12:32 am
- Location: Atlanta, GA
- Contact:
Re: How to redirect the non-www address to the www
Yeah, I agree with above. If you're getting a headache over it just throw in this plugin and you'll be fine.Pylon wrote:Although it's good to know what you can do with .htaccess and how to do it, you can address your www/non-www issues with this extension http://extensions.joomla.org/extensions ... adata/5355
-
- Joomla! Apprentice
- Posts: 32
- Joined: Sun Nov 15, 2009 9:14 pm
Re: How to redirect the non-www address to the www
THIS IS THE SOLUTIONJapanac033 wrote:If a web site is accessible under both http://www.example.com and example.com domains, you should be a responsible webmaster and remove the ambiguity altogether, through the following rewrite rules:
That should solve the problemCode: Select all
RewriteCond %{HTTP_HOST} ^example\.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Thanx!
- serrbiz
- Joomla! Enthusiast
- Posts: 231
- Joined: Mon Sep 18, 2006 3:48 pm
- Location: Dallas, TX
- Contact:
Re: How to redirect the non-www address to the www
We, like others, reccommend a .htaccess command line.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.you\.com
RewriteRule (.*) http://www.you.com/$1
However, if that doesn't work, you should contact your host provider and see if they have a different command they use...
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.you\.com
RewriteRule (.*) http://www.you.com/$1
However, if that doesn't work, you should contact your host provider and see if they have a different command they use...
- pe7er
- Joomla! Master
- Posts: 24986
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, Netherlands
- Contact:
Re: How to redirect the non-www address to the www
Some code that could be used without specifying your domain name:
Code: Select all
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,QSA]
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com