Rewrite www to non-www - directory other than root

Discuss Search Engine Optimization in relation to Joomla!. This forum will also have discussions on SEF/SEO Joomla! extensions.

Moderator: General Support Moderators

persona2020
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Wed Aug 13, 2008 7:13 am

Rewrite www to non-www - directory other than root

Postby persona2020 » Fri Jun 19, 2009 10:44 am

I have a Joomla installation (1.5.11) inside a folder in root directory and trying to rewrite 301 to redirect www to non-www for my domain.

I have tried the following code in .htaccess, but it's not working:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com/joomla-folder/
RewriteRule ^(.*)$ http://mydomain.com/joomla-folder/$1 [R=301,L]

Am I missing something? or it does not work in any folder other than the root? Please help...

persona2020
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Wed Aug 13, 2008 7:13 am

Re: Rewrite www to non-www - directory other than root

Postby persona2020 » Fri Jun 19, 2009 11:46 am

Okay, solved my problem with the following code:

RewriteBase /joomla-folder/
RewriteCond %{HTTP_HOST} ^www.mydomain\.com [NC]
RewriteRule (.*) http://mydomain.com/joomla-folder/$1 [R=301,L,NC]

It seems to be working fine so far. Please let me know if it's okay to use this...just a bit worried if it leads to any NOT Found page...

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Fri Apr 15, 2011 6:53 pm

im trying to set this up myself....

here is my .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

########## 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_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php






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




my question is how do i know if this is working?

-abatis

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Fri Apr 15, 2011 6:57 pm

ok, i found a tool and im showing this as not working. so my question is , what am i missing to make this be www to nonwww redirect?

thank you.
-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Fri Apr 15, 2011 7:40 pm

@persona2020

The initial code in the very first post in this thread failed because HTTP_HOST sees only the domain name. It cannot see the path part of any URL request. Therefore the pattern in the very first rule will never match any request.

Firstly, do you want to install this code in
http://example.com/.htaccess or in
http://example.com/joomla/.htaccess
because the code inside the file changes depending on the answer?

Next, does /joomla/ appear in the URLs for the pages of your site?
Again, this is a crucial piece of information affecting exactly what code will be used.



@abatis:

The redirect code at the end of your post just above this one fails because it fails to specify which server variable is being tested by the RewriteCond. Additionally, it is too late to perform an external redirect after the internal rewrites to the server filesystem have already been invoked. Attempting to do this will expose previously rewritten internal filepaths back out on to the web as new URLs. The code for redirects needs to be placed before the code for rewrites.

Additionally, the RewriteEngine directive is needed precisely once.

First, get a new .htaccess file. Use the one found in the new Joomla 1.5.23 version. The code is much more efficient than the file you have now. The new file also contains a note showing the precise place in the file that redirect codes, such as the one you want to use, should go.

Finally, use this code for the www to non-www redirection:

Code: Select all

RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule (.*) http://example.com/$1 [R=301,L]
Every character in that code, and especially the ! ^ ( ) ? and $ are important.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Sat Apr 16, 2011 1:28 pm

i found this page:

http://docs.joomla.org/Htaccess_examples_(security)#Suggested_Master_htaccess_file

would this be an acceptable source for building a replacement htaccess file?

thank you.
-abatis

also thanks for the quick and informative reply.

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Sat Apr 16, 2011 8:17 pm

You're not ready for the huge amount of work that the Security File will need for you to get it all working.

Use the right file from here:

1.5.x: http://joomlacode.org/gf/project/joomla ... sion=21081

1.6.x: http://joomlacode.org/gf/project/joomla ... sion=21101

These should be easy to work with.
Online since 1995.

redhurric
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Thu Dec 09, 2010 1:53 pm
Contact:

Re: Rewrite www to non-www - directory other than root

Postby redhurric » Sun Apr 17, 2011 3:21 am

Can anyone tell me whats the benefits of cutting out www
because i have seen lots of websites doing so
Some tell me its better for SEO
Is it?
Site about animals http://www.animalsguild.com
Facts about wild animals, endangered animals, and farm animals.

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Sun Apr 17, 2011 7:41 am

There is no SEO benefit to using non-www instead of www. It's purely that some people prefer the shorter URL.

The reason for the redirect from one to the other is the elimination of Duplicate Content problems. You should not let www and non-www both serve content with "200 OK" status. One should serve the content, the other should redirect to the canonical URL with status "301 Moved Permanently".

Although some people prefer using the shorter non-www URL, it is easier to diagnose certain problems with websites if the non-www is redirected to the www.

These two Google searches quickly show that www is the only version indexed:

site:www.example.com

site:example.com -inurl:www

This diagnosis isn't possible if the non-www is the version used by the site.

I prefer to redirect non-www to www. Even so, there are no issues whatsoever in promoting "example.com" non-www URLs in print media and on TV and in spoken radio advertising.

To be clear, type "google.com" into your web browser and see that Google redirects you to "www.google.com/". Has anyone ever told you to "make a search at www.google.com"? No, they will merely have said to search at "google.com".
Online since 1995.

newjoom_user
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Sun Oct 31, 2010 10:47 pm
Contact:

Re: Rewrite www to non-www - directory other than root

Postby newjoom_user » Sun Apr 17, 2011 9:01 am

If really it is creating a problem then go for component for redirects. if you go for sub domains like forum.joomla.org they will really help in seo but for a normal site with www is best because worlds major sites are prefering it.
http://www.interviewquestionseasy.com/
Interview Questions Easy
Interview Tips and Preparation

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Mon Apr 18, 2011 8:18 am

The cPanel solution writes very badly coded code.

You are better off avoiding that and pasting exactly correct code to your configuration file.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Mon Apr 18, 2011 12:53 pm

thank you for all the feedback. this has brought me to ask another question....

i understand your logic for saying to use the www instead of the nonwww. so my question is,,,,what if i already have linkbacks and all my internal site linking coded as the nonwww. i know its not a big deal so i could just keep this site as nonwww, but lets just say for example i wanted to change it...would i need to change my code to have the www in all my site links? because whichever you choose is how you should code it correct?

-abatis

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Mon Apr 18, 2011 1:46 pm

ok, im confused. i changed the file to this:
##
# @version $Id$
# @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 % ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]


########## 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


yet i am still unable to verify it is working?

-abatis

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Mon Apr 18, 2011 1:51 pm

not to be a bother, but i am now realizing that

www.mysite.com/index.php
mysite.com/index.php
www.mysite.com
mysite.com
www.mysite.com/index.html
mysite.com/index.html

are all showing, so i would somehow need to redirect all of these to just the one nonwww version of the mysite.com, im sure im missing something simple but any help is appreciated. thank you.

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Mon Apr 18, 2011 8:22 pm

There are several errors in this code, and it doesn't cater for some non-canonical variants:

Code: Select all

RewriteCond % ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]


More robust code for index files, www, port numbers and other non-canonical URLs:

Code: Select all

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

EDIT: IF Joomla is installed in a folder, the above code should be EITHER:
1. installed in the .htaccess file in the root of the site, OR
2. installed in the folder but the /$1 part of the code should be altered to say /folder/$1 instead.
Last edited by g1smd on Tue Apr 19, 2011 2:06 pm, edited 2 times in total.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Tue Apr 19, 2011 1:01 pm

bingo!!!! that nailed it.

or at least i think it did. it is now showing all of those urls that i listed above as perm redirects.

is this what i want it to do for the se to see it correctly?
even my root domain is a redirect now the way the tool is reporting this.



thank you so much for being so helpful and working with me on this.

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Tue Apr 19, 2011 1:33 pm

You can thank the guys in an earlier thread viewtopic.php?f=432&t=549841&start=150 for helping me to refine this code over a period of several weeks.

It's a lot more complicated than you might initially assume. It caters for more non-canonical variants than most people bother with. However, the code needs to have several exceptions and exclusions so that various extensions and plugins can continue to operate correctly. Those are already incorporated.

The version of the code if your site uses www URLs is as follows:

Code: Select all

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]

To use this code, fetch a copy of the .htaccess file used in Joomla 1.5.23 or later, or a copy of the .htaccess file used in Joomla 1.6.2 or later (those new files will work perfectly with older versions of Joomla), and paste the above code into the section of the file that mentions "place redirects here".

EDIT: IF Joomla is installed in a folder, the above code should be EITHER:
1. installed in the .htaccess file in the root of the site, OR
2. installed in the folder but the /$1 part of the code should be altered to say /folder/$1 instead.
Last edited by g1smd on Sat Apr 23, 2011 12:52 pm, edited 4 times in total.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Tue Apr 19, 2011 1:41 pm

currently my site is using the nonwww urls....so the proper one would be the first you posted ?

and this is ok even though it is redirect all of my urls?
* http://mysite.com returns a 301 (permanent) redirect
* http://www.mysite.com returns a 301 (permanent) redirect
* http://mysite.com/index.php returns a 301 (permanent) redirect
* http://www.mysite.com/index.php returns a 301 (permanent) redirect
* http://mysite.com/index.htm returns a 301 (permanent) redirect
* http://www.mysite.com/index.htm returns a 301 (permanent) redirect
* http://mysite.com/index.html returns a 301 (permanent) redirect
* http://www.mysite.com/index.html returns a 301 (permanent) redirect
* http://mysite.com/index.shtml returns a 301 (permanent) redirect
* http://www.mysite.com/index.shtml returns a 301 (permanent) redirect
* http://mysite.com/index.asp returns a 301 (permanent) redirect
* http://www.mysite.com/index.asp returns a 301 (permanent) redirect
* http://mysite.com/default.asp returns a 301 (permanent) redirect
* http://www.mysite.com/default.asp returns a 301 (permanent) redirect
* http://mysite.com/index.aspx returns a 301 (permanent) redirect
* http://www.mysite.com/index.aspx returns a 301 (permanent) redirect
* http://mysite.com/index.cfm returns a 301 (permanent) redirect
* http://www.mysite.com/index.cfm returns a 301 (permanent) redirect
* http://mysite.com/index.pl returns a 301 (permanent) redirect
* http://www.mysite.com/index.pl returns a 301 (permanent) redirect
* http://mysite.com/default.htm returns a 301 (permanent) redirect
* http://www.mysite.com/default.htm returns a 301 (permanent) redirect

i will go and thank them now. and thanks again.

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Tue Apr 19, 2011 2:00 pm

The status code is important, but so too is the DESTINATION.

Check where the requests are redirected to. That is important too.

The code above does not touch .aspx or .pl URLs (among others) so you must have some other rules installed that are redirecting those.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Tue Apr 19, 2011 3:29 pm

hmmm. i see, your correct. when i type them into the browser they are 404. guess i still have a lot to learn about htaccess. but this is a great start at least for the time being considering i was really only after the www to nonwww. thanks again for all the help. if you or anybody has any other info you would like to share on how to do these other redirects lmk here. thank you.

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Tue Apr 19, 2011 3:36 pm

URL requests ending in index.php, index.htm and index.html, for both www and non-www requests, should redirect to strip the filename and end up on the canonical domain. This should happen for index pages in the root or in a folder.

All other non-canonical URL requests for the root or for pages should redirect to the canonical domain (adding or removing the www as appropriate) and preserving the originally requested path within that redirect.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Wed Apr 20, 2011 3:04 pm

thanks again for all your help. it seems though, just as i thought i was getting to the bottom of this i have a new issue that seems to have been created by changing my htaccess file.

i will try to explain.
on our site, we have three forms to collect information for moving quotes. i am on a godaddy server using webformmailer provided by godaddy which seems to suck. so before i changed the htaccess file i had my form on submit redirecting the user to a thank you page and emailing me the form. so when they clicked submit 'redirect value="thankyou.html" should be shown. then from there they were redirected using meta refresh to our homepage.

i need these forms to work so for now i had to put my old htaccess file back online.
do you or does anyone have any ideas on why this would be happening and what i could do to fix it.

i hope that makes sense. lmk if more info is needed.

i really appreciate all the help.

-abatis

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Wed Apr 20, 2011 6:15 pm

to follow up i found the problem..

i had my formmailer.php file being called as the www.version and just had to change the path on my forms.

thanks.

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Wed Apr 20, 2011 7:48 pm

Thankfully it was something simple. For reference, you cannot redirect POST requests. If you do, all the appended parameters are always automatically stripped.

If it had been another issue, the fix would have been to add another RewriteCond exclusion before the RewriteRule so that the rule failed to run for certain requests.
Online since 1995.

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Fri Apr 22, 2011 12:42 pm

yeah, it was the thankyou.html page that is redirecting.

-abatis

abatis
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Mon Feb 28, 2011 5:36 pm

Re: Rewrite www to non-www - directory other than root

Postby abatis » Fri Apr 22, 2011 1:33 pm

would anyone have any info how i could redirect a single page....
joomla has this page:

mysite.com/component/content/article/46-welcome.html

which is the same content as mysite.com

-abatis

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Fri Apr 22, 2011 4:57 pm

abatis wrote:would anyone have any info how I could redirect a single page...
Joomla has this page:
mysite.com/component/content/article/46-welcome.html
which is the same content as mysite.com

Code: Select all

RewriteRule ^component/content/article/46-welcome\.html http://example.com/? [R=301,L]

The new rule goes ahead of all the more general redirects.
Online since 1995.

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

Re: Rewrite www to non-www - directory other than root

Postby g1smd » Fri Apr 22, 2011 5:40 pm

ronnelaton wrote:what is the purpose of removing www? is it one of search engine optimization factor that gives a high impact? I better have a research and have a study about seo... :geek:

There is no SEO benefit to using non-www instead of www. It's purely that some people prefer the shorter URL.

The reason for the redirect from one to the other is the elimination of Duplicate Content problems. You should not let www and non-www both serve content with "200 OK" status. One should serve the content, the other should redirect to the canonical URL with status "301 Moved Permanently".

Although some people prefer using the shorter non-www URL, it is easier to diagnose certain problems with websites if the non-www is redirected to the www.

These two Google searches quickly show that www is the only version indexed:

site:www.example.com

site:example.com -inurl:www

This diagnosis isn't possible if the non-www is the version used by the site.

I prefer to redirect non-www to www. Even so, there are no issues whatsoever in promoting "example.com" non-www URLs in print media and on TV and in spoken radio advertising.

To be clear, type "google.com" into your web browser and see that Google redirects you to "www.google.com/". Has anyone ever told you to "make a search at www.google.com"? No, they will merely have said to search at "google.com".
Online since 1995.

User avatar
joomfriend
Joomla! Explorer
Joomla! Explorer
Posts: 277
Joined: Sun Feb 08, 2009 5:10 pm
Contact:

Re: Rewrite www to non-www - directory other than root

Postby joomfriend » Mon Aug 01, 2011 3:39 pm

I am not into editing the .htaccess too much unless really needed. Assuming one is using a SEF/SEO component like SH404SEF, 301 redirect for given site broken links or deleted links can easily be done. Just enter the link to be redirected and voila! your are done!
Why then should we bother ourselves with editing .htaccess file (with all the risk due to coding or typo errors) while life is so easy using SEF Component (hassle-free solution)? Is it a good practice?
Just a thought ;)
- http://www.brasperto.com.br: BrasPerto - Free Business Website Directory
- http://www.egliseprimitive.org: Christian Website

james920
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jul 25, 2013 10:09 am

Re: Rewrite www to non-www - directory other than root

Postby james920 » Thu Jul 25, 2013 10:12 am

its very hard :geek:


Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 5 guests