Help! Issue with WWW in all web browsers & htaccess

Need help with the Administration of your Joomla! 1.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
cyphergt
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Tue May 17, 2011 7:10 pm

Help! Issue with WWW in all web browsers & htaccess

Post by cyphergt » Mon May 23, 2011 3:34 pm

I have Joomla version 1.5.23 and my issue is that I can log onto my site twice if I put in www. and if I take out www. Example: www.google.com or google.com it allows the user to log in each time and for some reason Internet explorer won't let you login using www. it just refreashes the page and doesn't log you in but in the back end under users it shows up as if you are logged in. The log in works just fine in ie if I take out the www. I have tried it on multiple pc's, removed all cookies and it still happens. I am using Yoologin but even with it deleted and using the standard login it still happens. I also have jomsocial on if that makes a diffrence. I have seen people complain about it online that they can't login using IE and some figured out that they could if the removed the www. some of them made mention that the htaccess file needed to be changed to the following but it doesn't seem to do anything.

RewriteEngine On
RewriteBase /
RewriteCond %(HTTP HOST) ^mydomain.com [NC]
RewriteRule ^(.*) http://www.mydomain.com/$1 [L, R=301]

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Mon May 23, 2011 3:58 pm

Perhaps the position of the code is significant ? http://forum.joomla.org/viewtopic.php?p ... 4#p2499734
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

cyphergt
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Tue May 17, 2011 7:10 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by cyphergt » Mon May 23, 2011 6:05 pm

I deleted all the login modules and just reinstalled yoologin and I can now login using www with ie but I still have two different ways to login one using www and the other without it. I what I would like to have happen is for anytime someone types in just the domain name example google.com that it would redirect it to www.google.com.

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by kurchania » Mon May 23, 2011 6:15 pm

browser treat www and non www as 2 different system
try this in .htaccess

Code: Select all

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
abhijeet kurchania
The future depends on what you do today

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Mon May 23, 2011 6:53 pm

cyphergt wrote: RewriteEngine On
RewriteBase /
RewriteCond %(HTTP HOST) ^mydomain.com [NC]
RewriteRule ^(.*) http://www.mydomain.com/$1 [L, R=301]
The %(HTTP_HOST) should be %{HTTP_HOST} here.
You MUST escape the literal periods in the pattern, so " . " should be " \. " here.
RewriteBase / is the default. You can delete this line.
The above code does not redirect all non-canonical hostnames. It fails to redirect www requests with appended port number or period.

kurchania wrote:RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
The above code fails to redirect non-www requests with appended port number or period.


Try this code (it fixes several issues):

Code: Select all

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.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]
#
########## End - 301 Redirect
I also urge you to use the new .htaccess file that comes with Joomla 1.5.23 onwards and Joomla 1.6.2 onwards. Look for the file called htaccess.txt in the installer package. It contains a note showing exactly where the redirects should go (in addition to a number of other changes). Add your new redirect code in the file at the point it says "redirects go here", or similar.

The rule order is critical. External redirects MUST be listed before internal rewrites. Additionally, once you have used RewriteRule in your .htaccess file you must NOT use Redirect or RedirectMatch at all.
Online since 1995.

cyphergt
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Tue May 17, 2011 7:10 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by cyphergt » Mon May 23, 2011 8:41 pm

The above code fails to redirect non-www requests with appended port number or period.
I also urge you to use the new .htaccess file that comes with Joomla 1.5.23 onwards and Joomla 1.6.2 onwards. Look for the file called htaccess.txt in the installer package. It contains a note showing exactly where the redirects should go (in addition to a number of other changes). Add your new redirect code in the file at the point it says "redirects go here", or similar.

The rule order is critical. External redirects MUST be listed before internal rewrites. Additionally, once you have used RewriteRule in your .htaccess file you must NOT use Redirect or RedirectMatch at all.
I don't have .htaccess file I have a htaccess file minus the period if I add a period to the front of that file I can no longer view my site it takes me to Iana.org and I then have to go to godaddy to change the file type since fireftp won't allow me to view it.

Thanks to you I have a better understand of the htaccess file but I am puzzled by the fact that I never had and .htaccess file. I had read on one forum that it had to be created which I did and it resulted in the above.

So just to be clear are my marching orders to add your script to the htaccess file I have or do I need to make a .htaccess file?

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Mon May 23, 2011 8:55 pm

Use the htaccess.txt file that comes with Joomla OR better yet get the newer version of the file that comes with Joomla 1.5.23 onwards or Joomla 1.6.2 onwards and use that.

Add the above code to the htaccess.txt file in exactly the right place. In the new version of the htaccess.txt file that comes with Joomla 1.5.23 onwards and Joomla 1.6.2 onwards there is a specific place in the file that tells you "redirects go here". It is important to get the rules in the right order.

In the code you add, change www.example.com to be your own domain name. Do that in every place in the file where you see www.example.com. Where you see www\.example\.com also change that, but make sure the periods are done as " \. " not just as " . " each time.

Upload the file to the server and then rename it as .htaccess so that the server can use it.
Last edited by g1smd on Mon May 23, 2011 8:58 pm, edited 2 times in total.
Online since 1995.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Mon May 23, 2011 8:57 pm

If you use Filezilla ftp client there is a setting to 'Force showing hidden files'
The . (full stop/period) denotes a hidden file.

Also gdddy cache their .htaccess files, so it may take a while before any changes show.

If your site does not work after following g1smd's instructions then the chances are that you made a (human) error following them.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

cyphergt
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Tue May 17, 2011 7:10 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by cyphergt » Mon May 23, 2011 9:44 pm

here is the htaccess.txt file with the changes

##
# @version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
# @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

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!
#
## 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
# 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 data within the URL
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
########## End - Rewrite rules to block out some common exploits


########## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.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]
#

########## End - Custom redirects


# 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
#
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 root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|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

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Mon May 23, 2011 11:46 pm

As long as you have changed "example" to be your real domain name (in at least 4 places), you're ready to go.
Online since 1995.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Tue May 24, 2011 12:10 am

Why have you got
www.example.com/
instead of your own url
???
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

cyphergt
Joomla! Apprentice
Joomla! Apprentice
Posts: 43
Joined: Tue May 17, 2011 7:10 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by cyphergt » Tue May 24, 2011 12:15 am

Sorry that's because all I did was put the script in I hadn't changed it yet but I did on mine here it is

##
# @version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
# @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

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!
#
## 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
# 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 data within the URL
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
########## End - Rewrite rules to block out some common exploits


########## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.askaliar.\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.askaliar.\com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.askaliar\.com)?$
RewriteRule (.*) http://www.askaliar\.com/$1 [R=301,L]
#

########## End - Custom redirects


# 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
#
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 root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|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

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Tue May 24, 2011 12:46 am

You completely messed up the instructions regarding " ." and " \. " here.

Where you see " www.example.com " put in your domain and retain the " . " between each part.

Where you see " www\.example\.com " put in your domain and retain the " \. " between each part.

Nowhere is " .\ " the correct thing to use.
Online since 1995.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Tue May 24, 2011 12:53 am

:laugh:
I see the problem and you will laugh as well when you know it. :D

g1smd used bb tags

Code: Select all

 and you used [quote

in normal and in [quote
The
{
looks like
(
If you click 'Quote' on his message you will see what I mean.


Computers are temperamental with precise text
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Tue May 24, 2011 1:01 am

If g1smd confirms, then this is it
Remember to click 'Quote' at the bottom of the post, so that you see it clearly.

Code: Select all

##
# @version $Id: htaccess.txt 21064 2011-04-03 22:12:19Z dextercowley $
# @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

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!
#
## 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
# 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 data within the URL
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
########## End - Rewrite rules to block out some common exploits


########## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.askaliar.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.askaliar.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.askaliar\.com)?$
RewriteRule (.*) http://www.askaliar.com/$1 [R=301,L]
#
########## End - 301 Redirect


########## End - Custom redirects


#  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
#
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 root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|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
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by kurchania » Wed May 25, 2011 4:46 am

@g1smd,
The above code fails to redirect non-www requests with appended port number or period.

Code: Select all

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
This code work perfect for me for last 3 year no issue
i never append port or period?thats something new
can you give me some real live example
@cyphergt
Rename htaccess.txt to .htaccess first.may be this doc is also usefull
http://docs.joomla.org/How_do_you_conve ... ss_file%3F
one more thing is it linux hosting or iis?
abhijeet kurchania
The future depends on what you do today

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Wed May 25, 2011 7:34 am

kurchania wrote:This code work perfect for me for last 3 year no issue. I never append port or period? That's something new. Can you give me some real live example?
A request for example.com./ (trailing period) or for example.com:80/ (trailing port number) will not be redirected by your code. Your code fails to redirect these Duplicate Content non-canonical URLs. You leave your site open to malicious linking from other sites.
Online since 1995.

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by kurchania » Wed May 25, 2011 3:30 pm

but i never see such things in live stuffs
abhijeet kurchania
The future depends on what you do today

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44091
Joined: Sat Apr 05, 2008 9:58 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by Webdongle » Wed May 25, 2011 4:35 pm

kurchania wrote:but i never see such things in live stuffs
And I can't see elephants in my back garden either. Does that mean elephant's don't exist ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
kurchania
Joomla! Hero
Joomla! Hero
Posts: 2070
Joined: Mon Sep 21, 2009 6:56 am
Location: indore,india
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by kurchania » Thu May 26, 2011 3:29 am

@Webdongle
don't know about that elephant but its just i learn something new again for www htaccess redirection.
you can learn only when u face it in in real. ;D ;D
@g1smd
thanx for you clarification i will update my redirection code.
abhijeet kurchania
The future depends on what you do today

hankin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Thu Mar 08, 2012 2:40 pm
Location: England
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by hankin » Thu Mar 08, 2012 2:46 pm

Hi, I know it's been a while since the last post here but I have a similar problem. I added the code from http://forum.joomla.org/viewtopic.php?t=692667 in the .htaccess file and then I was notified of a syntax error and since then my website redirects to http://www.iana.org/domains/example/. Even when I try to log into the backend to remove the change in the .htaccess file through domain/administrator I am redirected to the iana website! Can anyone help please?!

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: Help! Issue with WWW in all web browsers & htaccess

Post by g1smd » Thu Mar 08, 2012 7:43 pm

Use FTP to log in to your site and then edit the .htaccess file.

Change example.com in the example code to be your actual website.
Online since 1995.

hankin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Thu Mar 08, 2012 2:40 pm
Location: England
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by hankin » Tue Mar 13, 2012 2:07 pm

Thank you so much! I'm sorry for wasting your time. I renamed the .htaccess file and imported the original one. That restored everything to the way it was. I then edited the old .htaccess file and used the code you gave chenging example to my domain name and it has just worked. Thank you very much. It was a bit scary to see everypage of the domain including administrator log in redirecting to iana! All sorted. Thanks g1smd

sinasile
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Wed Dec 04, 2013 5:36 pm
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by sinasile » Sun Mar 16, 2014 10:09 pm

Thanks to those who share this solution for non-www to www it still work and it " finally " solve my problems with duplicate content

tmigot
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jan 11, 2013 5:36 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by tmigot » Wed Aug 13, 2014 4:02 am

Hi everyone,

i have been trying for hours and hours to make this redirection work using your code and others (aeSecure) and i always end up with the same outcome:

the main url won't load: http://tommigotphotography.com

Please note if you test this now it will work as the site is my business site and cannot afford to have it not functioning. I was told i needed to make this redirect work in order to be better referenced by google since it is duplicated my content for the moment. Any help would be highly appreciated. If test is needed i could of course apply suggestion and provide feedback.

Since Safari does not give much info (the dev tool says: "Failed to load resource: too many HTTP redirects") i tried with Firefox and i got this msg:
"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

here is the code i copied from you and modified with my own domain:
########## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.tommigotphotography.\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.tommigotphotography.\com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.tommigotphotography\.com)?$
RewriteRule (.*) http://www.tommigotphotography\.com/$1 [R=301,L]
#
########## End - Custom redirects

User avatar
dpacadmin
Joomla! Champion
Joomla! Champion
Posts: 6029
Joined: Sat Aug 16, 2008 1:46 pm
Location: the Bat Cave
Contact:

Re: Help! Issue with WWW in all web browsers & htaccess

Post by dpacadmin » Wed Aug 13, 2014 4:06 pm

@tmigot
What are you trying to accomplish with the redirects?

tmigot
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jan 11, 2013 5:36 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by tmigot » Thu Aug 14, 2014 12:08 am

@dpacadmin - thanks for engaging. I was told my site: http://TomMigotPhotography.com does not have an actual redirection from the url with "www" to the "non-www" url and therefore Google sees this as 2 different sites with same content and therefore duplicate and it has great impact on my referencing.

Reading this thread and other stuff online I wanted to fix the issue (just mentioned) but no matter what i have done i always get the whole site not working once amended so i end up reverting back to the original.

tmigot
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jan 11, 2013 5:36 pm

Re: Help! Issue with WWW in all web browsers & htaccess

Post by tmigot » Thu Aug 14, 2014 12:33 am

just been sorted out by the hosting provider. the trick was this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.tommigotphotography\.com$ [NC]
RewriteRule ^(.*)$ http://tommigotphotography.com/$1 [L,R=301]
</IfModule>


Locked

Return to “Administration 1.5”